Utilizing functions
High-order validators
export default function minLength(length) {
// returns a validator function expected by RAF
return ({ value, fieldProps, form }) => {
return value.length >= length
}
}import minLength from './validators/minLength'
const validationRules = {
type: {
tel: {
minLength: minLength(8),
},
},
name: {
firstName: {
minLength: minLength(2),
},
},
}Last updated