Skip to content

Incorrect Example + Description on Global SchemaΒ #277

Closed
@InfoDevkota

Description

@InfoDevkota

What is the type of issue?

Documentation is confusing

What is the issue?

On Essential -> Schema -> Global Schema,

Its is mentioned that we can define global schema using:

.schema followed by a life cycle event in camelCase:

Its not clear.

The provided code

    .schema({ 
        query: t.Object({ 
            name: t.String() 
        }) 
    }) 
    .get('/query', ({ query: { name } }) => name)

the code is incorrect, it throws an error:

  • This expression is not callable. (IDE help)
  • TypeError: Object is not a function (near '...}).schema({...') (Runtime)

Defining a guard on top level does the job of validating the request.

    .guard({
        query: t.Object({
            name: t.String()
        }),
    })
    .get('/query', ({ query: { name } }) => name)

If this is the case, We may need to to rephrase some description and update the example. I can send PR for this

If we can use the .schema, how can we do that?

Where did you find it?

Essential -> Schema -> Global Schema

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions