Skip to content

Commit

Permalink
Catch input name in error message
Browse files Browse the repository at this point in the history
  • Loading branch information
muath-ye committed Aug 3, 2022
1 parent 9b3a0e5 commit 2b3fe85
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions resources/views/components/forms/string-input.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function {{ str_replace('[]', '', $name) }}_stringInputUpdated(element) {
let inputIndex = "{{ str_replace('[]', '', $name) }}";
let rules = "{{ $rules }}"
let data = {
name: inputIndex,
inputIndex: element.value,
rules: {
inputIndex: rules
Expand Down
7 changes: 6 additions & 1 deletion src/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
use Illuminate\Support\Facades\Validator;

Route::post('validate', function (Request $request) {
$validator = Validator::make($request->all(), $request->rules);
$validator = Validator::make(
$request->all(),
$request->rules,
[],
['inputIndex' => $request->name]
);
if ($validator->fails()) {
return response()->json($validator->errors());
}
Expand Down

0 comments on commit 2b3fe85

Please sign in to comment.