Consider writing a set of pure high-order validator functions that accept optional set of parameters and always return a validator function expected by React Advanced Form:
validators/minLength.js
1
exportdefaultfunctionminLength(length){
2
// returns a validator function expected by RAF
3
return({ value, fieldProps, form })=>{
4
return value.length >= length
5
}
6
}
Copied!
Use the minLength function parametrically whenever necessary: