Resume
Validation hook to deal with React forms
Designed to be used with a single object, allowing strong autocompletion
The validation trigger is debounced to optimize performances
npm i formook --save
API
Validation schemas are made using a mix of :
- Yup (https://github.com/jquense/yup)
- Joi (https://hapi.dev/tutorials/validation/)
- Boolean validation functions, which can return strings as the error messages (meaning the validation result is assumed false). They are not present in joi, and unlike yup, they take the complete object in parameter
The validation will be triggered only when the object is updated
It forces you to update your object reference when you want to switch between schemas, but you should not need it as the dynamic schemas are made possible with functions
Note that Yup and Joi can't be used both at the same time, you need to use the function switchHighLevelValidation to define your schema library (yup by default)
; ;
Types
; ; ; ;
Example
; ; // If you are using joi switchHighLevelValidation"joi"; schema =; ;