I am working my backend with laravel
and I need to validate a password field and the confirmation field, for this I have the following validation rule (a summary):
$rules = [
'password' => 'required|min:5|confirmed',
'password_confirmation' => 'required',
];
and in the frontend I am working with vue.js
and a validation library vee-validate
, which looks more or less like this:
<div class="control-group">
<input type="password" v-validate="'required'" name="password" class="form-control" v-model="user.password">
<span class="red" v-show="errors.has('password')">{{ errors.first('password') }}</span>
</div>
<div class="control-group">
<input type="password" v-validate="'required|confirmed:password'" name="password_confirmation" class="form-control" v-model="user.password_confirmation">
<span class="red" v-show="errors.has('password_confirmation')">{{ errors.first('password_confirmation') }}</span>
</div>
and modified the library so that it receives and can show the validations that I send from Laravel. All this works correctly, my problem is that Laravel sends the message that the password confirmation is not the same, in the password field:
{"message":"The given data was invalid.","errors":{"password":["The password confirmation does not match."]}}
What is a problem for me because the field that is marked as an error will be the one with the name password, however I think this is not correct since the response message should refer to the password_confirmation field, this is the normal behavior de laravel for this case ?, can I change to the field referred to in the answer?