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

[Feature Request] Validation on path parameters #177

Closed
ecyrbe opened this issue Oct 11, 2022 Discussed in #176 · 1 comment
Closed

[Feature Request] Validation on path parameters #177

ecyrbe opened this issue Oct 11, 2022 Discussed in #176 · 1 comment
Labels
enhancement New feature or request hacktoberfest

Comments

@ecyrbe
Copy link
Owner

ecyrbe commented Oct 11, 2022

Discussed in #176

Originally posted by epotter2297 October 11, 2022
It would be really cool if there was a way to use zod to validate my path parameters. For example, if I have an endpoint like so:

{
    method: 'get',
    path: '/users/:id',
    alias: 'getUser',
    description: 'Get a user',
    response: z.object({
      id: z.number(),
      name: z.string().nullable(),
    }),
},

And I want to make sure that id is a valid UUID, I could do something like:

{
    method: 'get',
    path: '/users/:id',
    alias: 'getUser',
    description: 'Get a user',
    parameters: [
      {
        name: 'id',
        description: 'The user id',
        type: 'Path',
        schema: z.string().uuid(),
      },
    ],
    response: z.object({
      id: z.number(),
      name: z.string().nullable(),
    }),
},
```</div>
@ecyrbe ecyrbe added enhancement New feature or request hacktoberfest labels Oct 11, 2022
@ecyrbe
Copy link
Owner Author

ecyrbe commented Oct 13, 2022

available on zodios v10.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest
Projects
None yet
Development

No branches or pull requests

1 participant