Trimmed
Reject values with leading or trailing whitespace.
Validates that a value has no leading or trailing whitespace. Internal spaces are allowed — only the edges are checked.
| Config flag | Type | Description |
|---|
trimmed | boolean | When true, rejects values that start or end with whitespace. |
const form = useForm({
initialValues: { name: '' },
validationSchema: {
name: { trimmed: true },
},
});
import { V } from 'formify-js';
V.trimmed();
| Scenario | Message |
|---|
| Leading or trailing whitespace | Must not have leading or trailing whitespace |
| Value | Result |
|---|
'John Doe' | ✅ Valid |
' John' | ❌ Invalid (leading space) |
'Doe ' | ❌ Invalid (trailing space) |
- Lighter than
noWhitespace: internal spaces like the one in 'John Doe' pass.
- Use the global
trim option if you would rather silently remove edge whitespace than reject the value.