Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please, update the ReadMe. #153

Open
i-zimmerman opened this issue Dec 6, 2020 · 1 comment
Open

Please, update the ReadMe. #153

i-zimmerman opened this issue Dec 6, 2020 · 1 comment

Comments

@i-zimmerman
Copy link

i-zimmerman commented Dec 6, 2020

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

@coolusaHD
Copy link

Do you still need help with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants