0

I have a simple login form and i show a message if the user use a wrong password or username

js

onSignin() {
    axios.post(
        'api/user/signin',
        {
            email: this.email,
            password: this.password,
        },
        {
            headers: { 'X-Requested-With': 'XMLHttpRequest' },
        },
    ).then((response) => {
            this.$router.push('dashboard');
        }).catch((error) => {
            this.errors.add('credentials', 'Wrong user or Password'); //this message i want to move to the dictionary
        });
    },

html

<form action="POST" >
    <span v-show="errors.has('credentials')" class="help is-danger">{{ errors.first('credentials') }}</span>
    <p class="form-group">
    ...

this works, the the error message gets displayed, but how can i add this message to the dictionary, that i have all my messages in one place?

Gregor Voinov
  • 2,203
  • 7
  • 34
  • 52

1 Answers1

0

I got the answer there ;)

https://github.com/baianat/vee-validate/issues/963

Validator.dictionary.merge({
    en: {
        messages: {
          credentials: 'Wrong user or password'
    }
  }
});

const message = this.$validator.dictionary.getMessage('en', 'credentials');
this.errors.add('credentials', message); //this message i want to move to the dictionary
Gregor Voinov
  • 2,203
  • 7
  • 34
  • 52