Skip to content

When multiple validators, ignores specified error messages #9

Open
@petrgazarov

Description

@petrgazarov

When validate is used with an array, specified error messages are ignored. Instead, it's defaulting to the {field} is not valid default error message (per @PepperTeasdale 's suggestion, adding required: true solved this specific problem, but it shouldn't need that extra key)

Example schema:

{
      ageDied: {
        validate: [
          {
            ...isPresent,
            validateIf: ({ diedFromDisease }) => diedFromDisease
          },
          {
            validator: ({ ageContracted }, value) => parseInt(ageContracted) < parseInt(value),
            errorMessage: 'this field cannot be before Age Contracted',
            required: true, // to be removed
            validateIf: ({ diedFromDisease }) => diedFromDisease
          },
        ]
      },
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions