length
Named Props
Parameters
Usage
import validate, {length} from 'strickland';
// As value parameters
const maxLengthBetween5and10 = length(5, 10);
// As named props
const maxLengthBetween10and20 = length({
minLength: 10,
maxLength: 20,
message: 'Must have a length between 10 and 20'
});
// As a function that resolves to have the named props
const lengthValidator = length((context) => ({
minLength: context.minLength,
maxLength: context.maxLength,
message: `Must have a length between ${context.minLength} and ${context.maxLength}`
}));Last updated