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

Error when validate a custom form #124

Open
jfrag opened this issue Mar 25, 2022 · 1 comment
Open

Error when validate a custom form #124

jfrag opened this issue Mar 25, 2022 · 1 comment

Comments

@jfrag
Copy link
Contributor

jfrag commented Mar 25, 2022

Hi,

I just updated BamUI for a project (from 9.x to 10.x).
I have an error when i use the validator plugin.

export default {
  data() {
    return {
      formValidation: {
        validMsg: {},
        validator: useValidator(),
        login: {
          username: {
            label: "Identifiant",
            validator:'required',
          },
          pwd: {
            label: "Mot de passe",
            validator:'required',
          }
        }
      },
      signIn: {
        username: null,
        pwd: null
      }
    }
  },
  methods: {
    login() {
      this.formValidation.validator.set(this.formValidation.login);
      let {valid, validMsg} = this.formValidation.validator.validate(this.signIn);
      this.formValidation.validMsg = validMsg;
      
      if (valid) {
        signInWithEmailAndPassword(auth, this.signIn.username, this.signIn.pwd).then(() => {
          this.$router.push('/')
        }).catch(err => {
          this.$toast(err.message);
        })
      }
    }
  }
}
Uncaught TypeError: Cannot set property openBlock of #<Object> which has only a gette

i don't have the error when i remove the custom validations

@elf-mouse
Copy link
Member

Hi @jfrag , recommend you to upgrade to 10.8.x

export default {
  data() {
    return {
      formValidation: {
        validMsg: {},
        // new verifications definition since 10.8.0
        login: [
          {
            key: 'username',
            label: 'Identifiant',
            validator: 'required'
          },
          {
            key: 'pwd',
            label: 'Mot de passe',
            validator: 'required'
          }
        ]
      },
      signIn: {
        username: '',
        pwd: ''
      }
    };
  },
  methods: {
    login() {
      this.$validator.set(this.formValidation.login);
      let { valid, validMsg } = this.$validator.validate(this.signIn);
      this.formValidation.validMsg = validMsg;

      if (valid) {
        // your code
      }
    }
  }
};

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