Formify Docs

One Of

Require the value to be one of a fixed set of allowed values.

One Of

Validates that a value equals one of the items in a fixed list of allowed values. Useful for dropdowns, status fields, and single-choice questions.

Configuration

Config flagTypeDescription
oneOfunknown[]List of allowed values.
oneOf[unknown[], string]Tuple form — the list plus a custom message.

With useForm

const form = useForm({
  initialValues: { status: '' },
  validationSchema: {
    status: { oneOf: ['active', 'paused', 'archived'] },
  },
});

With a custom message:

status: { oneOf: [['active', 'paused', 'archived'], 'Pick a valid status'] }

With the V builder

import { V } from 'formify-js';

V.oneOf(['active', 'paused', 'archived']);

Default message

ScenarioMessage
Value is not in the listMust be one of: active, paused, archived (the list is generated from your values)

Examples

ValueRuleResult
'active'oneOf: ['active', 'paused']✅ Valid
'deleted'oneOf: ['active', 'paused']❌ Invalid

Notes

  • Comparison is strict (===) and case-sensitive: 'Active' fails when the list contains 'active'.
  • The default message names every allowed value, so users see exactly what is acceptable.
  • Use notOneOf when the requirement is the inverse (a blocklist).

On this page