Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Example + Description on Global Schema #277

Closed
InfoDevkota opened this issue Feb 28, 2024 · 2 comments
Closed

Incorrect Example + Description on Global Schema #277

InfoDevkota opened this issue Feb 28, 2024 · 2 comments

Comments

@InfoDevkota
Copy link
Contributor

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

@InfoDevkota
Copy link
Contributor Author

It was already mentioned on #270 and #215.
as mentioned by SaltyAom on #215 I will send a PR with .guard

@InfoDevkota
Copy link
Contributor Author

fix by #283

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant