SSN
Validate US Social Security Numbers.
Validates that a value is a US Social Security Number. Both the dashed and plain digit forms are accepted.
| Config flag | Type | Description |
|---|
ssn | boolean | When true, requires the value to be a valid US SSN. |
const form = useForm({
initialValues: { ssn: '' },
validationSchema: {
ssn: { ssn: true },
},
});
import { V } from 'formify-js';
V.ssn();
| Scenario | Message |
|---|
| Value is not a valid SSN | Must be a valid Social Security Number |
| Value | Result |
|---|
'123-45-6789' | ✅ Valid |
'123456789' | ✅ Valid |
'123-45-678' | ❌ Invalid (too short) |
'123-45-67890' | ❌ Invalid (too long) |
- The
###-##-#### shape is enforced — with or without dashes.
- Pair with the
ssn formatter (format: "ssn") to auto-format the input as the user types — see Formatters.
- Empty values pass unless
required: true is also set.