Formify Docs

Hex

Validate hexadecimal strings without a leading

Hex

Validates that a value is a hexadecimal string — digits 0-9 and letters a-f only. Unlike hexColor, no # prefix is expected.

Configuration

Config flagTypeDescription
hexbooleanWhen true, requires the value to be valid hexadecimal.

With useForm

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

With the V builder

import { V } from 'formify-js';

V.hex();

Default message

ScenarioMessage
Non-hex characters presentMust be valid hexadecimal

Examples

ValueResult
'1A2b3C'✅ Valid
'deadbeef'✅ Valid
'0xFF'❌ Invalid (0x prefix not allowed)
'#fff'❌ Invalid (# not allowed)
'hello'❌ Invalid (l and o are not hex digits)

Notes

  • Case-insensitive: 'ABCDEF' and 'abcdef' both pass.
  • For color codes with the # prefix, use hexColor instead.

On this page