Skip to content

identical

Validates that a field's value is equal to another field's value (or a fixed string).

Options

OptionTypeDefaultDescription
comparestringrequiredField name to compare against, or a fixed value
trimbooleanfalseTrim whitespace from both values before comparing
messagestringlocale defaultCustom error message

Playground

Valid values

ValueNotes
Same as the password fieldValues match

Invalid values

ValueReason
Different from the password fieldValues do not match

Notes

  • Empty string ("") always returns valid: true — validators only run on non-empty values. Combine with notEmpty if the field is required.
  • compare can be a field name (resolved at validation time) or a fixed string literal.

Released under the MIT License.