Formify Docs

Not One Of

Reject values that appear in a forbidden list.

Not One Of

Validates that a value does not equal any item in a forbidden list. Useful for blocklists — reserved usernames, disallowed categories, banned coupon codes, and similar.

Configuration

Config flagTypeDescription
notOneOfunknown[]List of forbidden values.
notOneOf[unknown[], string]Tuple form — the list plus a custom message.

With useForm

const form = useForm({
  initialValues: { username: '' },
  validationSchema: {
    username: {
      notOneOf: ['admin', 'root', 'support'],
    },
  },
});

With a custom message:

username: { notOneOf: [['admin', 'root'], 'That username is reserved'] }

With the V builder

import { V } from 'formify-js';

V.notOneOf(['admin', 'root', 'support']);

Default message

ScenarioMessage
Value is in the forbidden listMust not be one of: admin, root, support (the list is generated from your values)

Examples

ValueRuleResult
'john'notOneOf: ['admin', 'root']✅ Valid
'admin'notOneOf: ['admin', 'root']❌ Invalid

Notes

  • Comparison is strict (===) and case-sensitive: 'Admin' is allowed when the list contains 'admin'.
  • Combine with oneOf when a value must be in one list but not another.

On this page