Formify Docs

Username

Validate usernames — letters, digits, underscores, and dots, 3–20 characters.

Username

Validates that a value is a valid username: letters, digits, underscores, and dots only, 3–20 characters long.

Configuration

Config flagTypeDescription
usernamebooleanWhen true, requires the value to match the username rules.

With useForm

const form = useForm({
  initialValues: { username: '' },
  validationSchema: {
    username: { username: true },
  },
});

With the V builder

import { V } from 'formify-js';

V.username();

Default message

ScenarioMessage
Invalid characters or lengthMust be 3–20 characters: letters, numbers, underscores or dots

Examples

ValueResult
'john_doe'✅ Valid
'john.doe'✅ Valid
'ab'❌ Invalid (too short)
'john-doe'❌ Invalid (dash not allowed)
'john doe'❌ Invalid (space not allowed)

Notes

  • 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.

On this page