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

Issues with validators #270

Open
davidma415 opened this issue Dec 2, 2020 · 0 comments
Open

Issues with validators #270

davidma415 opened this issue Dec 2, 2020 · 0 comments

Comments

@davidma415
Copy link

Code Snippet

  @tracked model = {
    newPassword: '',
    confirmPassword: ''
  };
  @tracked validatorsAreLoaded = false;
  constructor() {
    super(...arguments);
    this.createFormValidations();
  }
  async createFormValidations() {
    await this.passwordStrength.load();
    this.setPasswordValidation = {
      newPassword: [
        validatePresence({presence: true}),
        validateLength({
          min: this.minLength,
          max: this.maxLength
        }),
        validatePasswordStrength({
          minScore: 3,
          passwordStrengthService: this.passwordStrength,
          passwordStrengthResults: this.passwordStrengthResult,
          message: this.intl.lookup('validations.passwordStrength')
        })],
      confirmPassword: [
        validateConfirmation({
          on: 'newPassword',
          message: this.intl.lookup('validations.passwordsDoNotMatch')
        })]
    };
    this.formChangeset = new Changeset(
      this.model,
      lookupValidator(this.setPasswordValidation),
      this.setPasswordValidation
    );
    this.validatorsAreLoaded = true;
  }

Version

3.10.0

Expected Behavior

Expect it to validate the new password / confirm password with the validators.

Actual Behavior

The only validator that runs is validatePasswordStrength which is a custom validator I've created. Any help would be appreciated. validateConfirmation always evaluates to true even when there's nothing in newPassword, and newPassword doesn't seem to be evaluated either.

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

1 participant