0

I've created a FormRequest to validate some fields, and I would like that one of those fields only accept the options that a I give it

Searching I found something like this

"rule" => 'required|in:Option1,Option2,Option3',

This accept only the predifined options, but in the error message only shows

"The rule type is invalid."

And I would like that too shows the valid options predefined in the rules. How could i do this?

1

1 Answer 1

0

In the end I modified my rule to this:

"rule" => ['required', 'in:Option1,Option2,Option3']

and I customized the error message with the following

public function messages()
    {
        return [
            'rule.in' => 'The rule field must be Option1, Option2 or Option3.'
        ];
    }
Sign up to request clarification or add additional context in comments.

Comments

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.