react-material-ui-form-validator icon indicating copy to clipboard operation
react-material-ui-form-validator copied to clipboard

Please, update the ReadMe.

Open i-zimmerman opened this issue 5 years ago • 1 comments

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");
  });

Screenshot 2020-12-06 at 17 39 04

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");
      }
    };
  });

i-zimmerman avatar Dec 06 '20 14:12 i-zimmerman

Do you still need help with this?

coolusaHD avatar Jul 23 '22 09:07 coolusaHD