react-material-ui-form-validator
react-material-ui-form-validator copied to clipboard
Please, update the ReadMe.
When i try to use the following code from Readme, i get the following error: 1.
useEffect(() => {
ValidatorForm.addValidationRule("isPasswordMatch", (value) => {
if (value !== state.password) {
return false;
}
return true;
});
return ValidatorForm.removeValidationRule("isPasswordMatch");
});
Solution: use code from the DEMO.
My case - React hooks:
useEffect(() => {
if (!ValidatorForm.hasValidationRule("isPasswordMatch")) {
ValidatorForm.addValidationRule("isPasswordMatch", (value) => {
if (value !== state.password) {
return false;
}
return true;
});
}
return function cleanPasswordMatchRule() {
if (ValidatorForm.hasValidationRule("isPasswordMatch")) {
ValidatorForm.removeValidationRule("isPasswordMatch");
}
};
});
Do you still need help with this?