Andrey
Andrey

Reputation: 93

Validation vue laravel, change text-error

I loaded a package "Vue Laravel Validator" to validate in vue. Example:

<input id="name"  v-validate="'min:6|max:46|required'" type="text" name="title" class="form-control" required v-model="title">

                <div class="help-block with-errors" v-show="errors.has('title')">В название:
                    <a> {{ errors.first('title') }}</a>
                </div>

And display error: The title field must be at least 6 characters.
How can i change text in error? For example: "the title only 6 characters"

Upvotes: 0

Views: 669

Answers (1)

Sateesh
Sateesh

Reputation: 1336

You can set custom message in Laravel validation (server side)

public function save(Request $request){
  $validation = $this->validate($request, [
    'name' => 'required|min:3|max:32'
  ],[
    'name.required' => 'Name is required',
    'name.min' => 'Name should be greater than 3 characters',
    'name.max' => 'Name should be less than 32 characters'
  ]);

  if($validation->fails()){
     return response()->json($validation->errors()->all());
  }
}

Upvotes: 1

Related Questions