Formify Docs

Slug

Validate URL slugs — lowercase letters, digits, and hyphens.

Slug

Validates that a value is a URL slug: lowercase letters, digits, and hyphens, with no leading or trailing hyphen.

Configuration

Config flagTypeDescription
slugbooleanWhen true, requires the value to be a valid slug.

With useForm

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

With the V builder

import { V } from 'formify-js';

V.slug();

Default message

ScenarioMessage
Value is not a valid slugMust be a valid slug

Examples

ValueResult
'my-blog-post'✅ Valid
'post-2024'✅ Valid
'My-Blog'❌ Invalid (uppercase)
'-post'❌ Invalid (leading hyphen)

Notes

  • Only lowercase a-z, digits, and internal hyphens are accepted — underscores and uppercase letters fail.
  • If your content system auto-generates slugs, use this validator as a safety check before submit.

On this page