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

0

2 Answers 2

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

Look at the Laravel validation docs for more information

Sign up to request clarification or add additional context in comments.

6 Comments

If you see my question, my code strictly follows the laravel validation rules written in the documentation. You can see it here: laravel.com/docs/5.8/validation#validating-arrays. My question is not that
Problem is in vaidation response. The error is not shown
Do you have error block in your view code?Do you compose it?
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
do you have below code in your view file? ` @foreach ($errors->all() as $error) {!! $errors->first() !!} @endforeach `
|
-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

1 Comment

This does not answer the question

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.