Username
Validate usernames — letters, digits, underscores, and dots, 3–20 characters.
Validates that a value is a valid username: letters, digits, underscores, and dots only, 3–20 characters long.
| Config flag | Type | Description |
|---|
username | boolean | When true, requires the value to match the username rules. |
const form = useForm({
initialValues: { username: '' },
validationSchema: {
username: { username: true },
},
});
import { V } from 'formify-js';
V.username();
| Scenario | Message |
|---|
| Invalid characters or length | Must be 3–20 characters: letters, numbers, underscores or dots |
| Value | Result |
|---|
'john_doe' | ✅ Valid |
'john.doe' | ✅ Valid |
'ab' | ❌ Invalid (too short) |
'john-doe' | ❌ Invalid (dash not allowed) |
'john doe' | ❌ Invalid (space not allowed) |
- Allowed characters are exactly
a-z, A-Z, 0-9, _, and . — no other punctuation.
- Length is fixed at
3–20 characters; it is not configurable.
- Combine with
uniqueCheck for server-side availability checks — see the Async Validation guide.