Formify Docs

SSN

Validate US Social Security Numbers.

SSN

Validates that a value is a US Social Security Number. Both the dashed and plain digit forms are accepted.

Configuration

Config flagTypeDescription
ssnbooleanWhen true, requires the value to be a valid US SSN.

With useForm

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

With the V builder

import { V } from 'formify-js';

V.ssn();

Default message

ScenarioMessage
Value is not a valid SSNMust be a valid Social Security Number

Examples

ValueResult
'123-45-6789'✅ Valid
'123456789'✅ Valid
'123-45-678'❌ Invalid (too short)
'123-45-67890'❌ Invalid (too long)

Things to know

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

On this page