maxLength
Named Props
Parameters
Usage
import validate, {maxLength} from 'strickland';
// As a value parameter
const maxLengthOf3 = maxLength(3);
// As a named prop
const maxLengthOf2 = maxLength({
maxLength: 2,
message: 'Must have a length of at most 2'
});
// As a function that resolves to have the named prop
const maxLengthValidator = maxLength((context) => ({
maxLength: context.maxLength,
message: `Must have a length of at most ${context.maxLength}`
}));Last updated