Formify Docs

Domain

Validate domain names without the protocol or path.

Domain

Validates that a value is a domain name — labels separated by dots, with a valid top-level domain. The protocol (https://), port, and path are not part of the accepted format.

Configuration

Config flagTypeDescription
domainbooleanWhen true, requires the value to be a valid domain name.

With useForm

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

With the V builder

import { V } from 'formify-js';

V.domain();

Default message

ScenarioMessage
Value is not a domainMust be a valid domain name

Examples

ValueResult
'example.com'✅ Valid
'sub.domain.co.uk'✅ Valid
'https://example.com'❌ Invalid (protocol not allowed)
'example'❌ Invalid (no TLD)

Notes

  • For full URLs (with protocol, port, query), use the url validator instead.
  • Both the domain and url validators can be combined when a field should accept either form — see the V.any composition.

On this page