Skip to main content

hasMinLength()

const hasMinLength: (value, minLength, fieldName) => string;

Validates that a field meets the minimum length requirement

Parameters

ParameterTypeDescription
valuestringThe input value to validate
minLengthnumberThe minimum required length
fieldNamestringThe name of the field for error messages

Returns

string

Empty string if valid, error message if invalid

Example

hasMinLength("ab", 3, "Username") // Returns: "Username must be at least 3 characters."
hasMinLength("abc", 3, "Username") // Returns: ""