Formify Docs

Confirm

Require a field to match the value of another field.

Confirm

Validates that a value matches the value of another field in the same form. The classic use case is a "confirm password" field.

Configuration

Config flagTypeDescription
confirmstringThe name of the field whose value must match.
confirm[string, string]Tuple form — the target field plus a custom message.

With useForm

const form = useForm({
  initialValues: { password: '', confirmPassword: '' },
  validationSchema: {
    confirmPassword: { confirm: 'password' },
  },
});

With a custom message — and re-validate whenever the target field changes:

confirmPassword: {
  confirm: ['password', 'Passwords do not match'],
  deps: ['password'],
}

With the V builder

import { V } from 'formify-js';

V.confirm('password');

Default message

ScenarioMessage
Values do not matchDoes not match password (the message names the target field)

Notes

  • The referenced field must exist in initialValues; the check reads the current value of that field on each validation run.
  • The target field itself should carry its own rules (e.g. minLength); confirm only checks equality.
  • Pair with getFieldValues / field-level validate functions if you need more complex cross-field logic.

On this page