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

ajvConfigParams not respected in body validations #108

Open
robaca opened this issue Apr 27, 2023 · 0 comments
Open

ajvConfigParams not respected in body validations #108

robaca opened this issue Apr 27, 2023 · 0 comments

Comments

@robaca
Copy link

robaca commented Apr 27, 2023

We created a custom format for phone numbers. As it is a function and not a regexp, I tried to pass it to Ajv via the following options:

   this.validator = buildSchemaSync(this.spec, {
            ajvConfigParams: {
                formats: {
                    email: emailValidator.validate,
                    phone: phoneValidator.validate,   // <-
                },
            },
        })

For request parameters, this is working fine, but when I validate arequest body with this format, it failing with the following message:

Error: unknown format "phone" is used in schema at path "#/anyOf/1/properties/phoneNumber"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant