Formify Docs

ZIP / Postal Code

Validate US ZIP codes, with optional ZIP+4 support.

ZIP / Postal Code

Validates that a value is a US ZIP code. Both the 5-digit form and the ZIP+4 extended form are accepted.

Configuration

Config flagTypeDescription
zipbooleanWhen true, requires the value to be a valid US ZIP code.

With useForm

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

With the V builder

import { V } from 'formify-js';

V.zip();

Default message

ScenarioMessage
Value is not a valid ZIP codeMust be a valid ZIP code

Examples

ValueResult
'10001'✅ Valid
'10001-4321'✅ Valid (ZIP+4)
'1000'❌ Invalid (too short)
'10A01'❌ Invalid (letters)

Notes

  • ZIP+4 (12345-6789) is accepted without any extra configuration.
  • This validator targets US ZIP codes only. For other countries' postal codes, use the pattern validator with the appropriate regex.

On this page