useValidation

useValidations is a custom hook that provides a yup validation. This hook provides an object with two properties: errors and isValid. useValidation will be called every time when values are changed.

PropertyDescription
errorsObject with all errors, this object is the same shape of object values.
isValidBoolean property
const validation = yup.object().shape({
name: yup.string().required('This field is required'),
email: yup
.string()
.email('This field must be a valid e-mail')
.required('This field is required'),
pets: yup.array(yup.string().required('This field is required')),
accept: yup.bool().oneOf([true], 'Field must be checked')
})
const { errors, isValid } = useValidation(values, validation)