Skip to content

ajvConfigParams not respected in body validations #108

@robaca

Description

@robaca

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"

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