xxxxxxxxxx
This answer for who face the validation message error,
EX:// the validation error message => "validation.required"
// your lanaguage files has been deleted for validation,
// check this file /resoureces/lang/en/validation.php
xxxxxxxxxx
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<input id="title"
type="text"
name="title"
class="@error('title') is-invalid @enderror">
@error('title')
<div class="alert alert-danger">{{ $message }}</div>
@enderror
xxxxxxxxxx
@if ($errors->has('email'))
<span class="text-danger">{{ $errors->first('email') }}</span>
@endif
xxxxxxxxxx
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
xxxxxxxxxx
$messages = $validator->errors()->getMessages();
var_dump($messages);
xxxxxxxxxx
@if($errors->any())
@foreach ($errors->all() as $error)
<div>{{ $error }}</div>
@endforeach
@endif
xxxxxxxxxx
$validator = Validator::make(
$request->all(),
[
'profile_img' => 'required|mimes:jpeg,png,jpg|max:1024'
],
[
'profile_img.mimes' => 'Profile image must be a file of type: jpeg, png, jpg.',
]
);
if ($validator->fails()) {
return response()->json(['status' => '0', 'error' => $validator->errors()->toArray(), 'request' => $request->all()], 422);
} else {
return response()->json(['status' => '1','data'=>'validation success' , 200);
}
xxxxxxxxxx
<!-- /resources/views/post/create.blade.php -->
<label for="title">Post Title</label>
<input id="title"
type="text"
name="title"
class="@error('title') is-invalid @enderror">
@error('title')
<div class="alert alert-danger">{{ $message }}</div>
@enderror
xxxxxxxxxx
$messages = [
'same' => 'The :attribute and :other must match.',
'size' => 'The :attribute must be exactly :size.',
'between' => 'The :attribute value :input is not between :min - :max.',
'in' => 'The :attribute must be one of the following types: :values',
];