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 flag | Type | Description |
|---|---|---|
notOneOf | unknown[] | 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
| Scenario | Message |
|---|---|
| Value is in the forbidden list | Must not be one of: admin, root, support (the list is generated from your values) |
Examples
| Value | Rule | Result |
|---|---|---|
'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
oneOfwhen a value must be in one list but not another.