@petrichorjs/validator-vinejs
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@petrichorjs/validator-vinejs

Validate request bodies or query parameters with vinejs.

Installation

This package requires that you have vinejs installed.

$ npm i @vinejs/vine @petrichorjs/validator-vinejs

Docs

To use this validator you just have to pass the validator function to either the body or query validator depending on what you want to validate. You also have to pass the vinejs schema to the validator function.

router
    .post("/users")
    .validate({
        body: validator(
            vine.object({
                id: vine.number().withoutDecimals(),
                email: vine.string().email(),
                profile: vine.object({
                    username: vine.string(),
                }),
            })
        ),
    })
    .handle(async ({ request, response }) => {
        const data = await request.json();
        data; // { id: number, email: string, profile: { username: string }}
    });

Readme

Keywords

none

Package Sidebar

Install

npm i @petrichorjs/validator-vinejs

Weekly Downloads

2

Version

1.0.1

License

none

Unpacked Size

4.39 kB

Total Files

5

Last publish

Collaborators

  • vl07