0

Firstly I can say that after search I dont find any solution about this. I do validation array like this post: laravel validation array

I need validate each size array position. I write this validation code:

   // Fields validation
    $request->validate([
        'name' => 'required|max:150',
        'theySay' => 'nullable|array',
        'theySay.*' => 'string|max:1000',
        'theyDontSay' => 'nullable|array',
        'theyDontSay.*' => 'string|max:1000',
    ]

Where theySay and theyDontSay are both array of strings. In migration I have both fields (text) like strings of 1000 characters.

        $table->string('text', 1000);

And validation works correctly. I mean, if put a text greater than 1000 chars I cannot save but..dont show any error message.

I want the error message to be shown in the input just like the rest of the fields.

What am I doing wrong?

enter image description here

enter image description here

Best regards

JJMontalban
  • 100
  • 6

2 Answers2

1
'YOUR_FIELD' => '...|...|max:1000| ...'

Look at the Laravel validation docs for more information

masoud
  • 98
  • 1
  • 8
  • If you see my question, my code strictly follows the laravel validation rules written in the documentation. You can see it here: https://laravel.com/docs/5.8/validation#validating-arrays. My question is not that – JJMontalban Jul 01 '19 at 10:27
  • Problem is in vaidation response. The error is not shown – JJMontalban Jul 01 '19 at 10:31
  • Do you have error block in your view code?Do you compose it? – masoud Jul 01 '19 at 10:36
  • Any error in console is showed. If I enter a string <1000 I dont have any problem (validation works). But if I enter a string > 1000 validation works and I cannot save the element. But error dont appear. I update my question – JJMontalban Jul 01 '19 at 10:45
  • do you have below code in your view file? ` @foreach ($errors->all() as $error) {!! $errors->first() !!} @endforeach ` – masoud Jul 01 '19 at 11:00
  • If I put these code result is the same. Any error is showed – JJMontalban Jul 01 '19 at 12:29
-2

Please put below code in your blade file for show any error message.

@if ($errors->any())
    <div class="alert alert-danger">
        <ul>
            @foreach ($errors->all() as $error)
                <li>{{ $error }}</li>
            @endforeach
        </ul>
    </div>
@endif