Formify Docs

Starts With

Require a value to begin with a specific prefix.

Starts With

Validates that a value starts with a given prefix string.

Configuration

Config flagTypeDescription
startsWithstringThe required prefix.
startsWith[string, string]Tuple form — the prefix plus a custom message.

With useForm

const form = useForm({
  initialValues: { orderId: '' },
  validationSchema: {
    orderId: { startsWith: 'ORD-' },
  },
});

With a custom message:

orderId: { startsWith: ['ORD-', 'Order IDs start with ORD-'] }

With the V builder

import { V } from 'formify-js';

V.startsWith('ORD-');

Default message

ScenarioMessage
Value does not start with the prefixMust start with "ORD-" (the message names your prefix)

Examples

ValueRuleResult
'ORD-123'startsWith: 'ORD-'✅ Valid
'123-ORD'startsWith: 'ORD-'❌ Invalid

Notes

  • The check is case-sensitive: 'ord-123' fails when the prefix is 'ORD-'.
  • Combine with pattern or other rules when the remainder of the value also has a format.

On this page