Skip to content

different ​

Validates that a field's value is different from 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
Different from the currentPassword fieldValues differ

Invalid values ​

ValueReason
Same as the currentPassword fieldValues 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 or a fixed string literal.

Released under the MIT License.