Formify Docs

Min Length

Enforce a minimum string length.

Min Length

Validates that a string is at least a given number of characters long.

Configuration

Config flagTypeDescription
minLengthnumberMinimum number of characters.
minLength[number, string]Tuple form — the length plus a custom message.

With useForm

const form = useForm({
  initialValues: { name: '' },
  validationSchema: {
    name: { minLength: 3 },
  },
});

With a custom message:

name: { minLength: [3, 'At least {min} characters'] }

With the V builder

import { V } from 'formify-js';

V.minLength(3);

Default message

ScenarioMessage
Value is shorter than the minimumMust be at least 3 characters (the number reflects your value)

Examples

ValueRuleResult
'ab'minLength: 3❌ Invalid
'abc'minLength: 3✅ Valid
'abcd'minLength: 3✅ Valid

Notes

  • The check is inclusive: a value of exactly 3 characters passes minLength: 3.
  • Emoji count as single characters in JavaScript string length.
  • Combine with maxLength to define an exact allowed range.

On this page