Laravel
How to allow only numbers from 0 to 2 in Laravel validation
Thank you for your continued support.
This article contains advertisements that help fund our operations.
Table Of Contents
オススメ本
⇨ Check out the table of contents for Laravel articles here
This article discusses how to allow numbers from 0 to 2 in Laravel validation.
【Related Article】This article uses form requests
Conclusion
Using in
public function rules()
{
return [
'categoryId' => 'integer|in:0,1,2'
]
}
For a small number of options like this, I think specifying it succinctly like this is sufficient.
Summary
While it's a very limited case in terms of validation, I wrote about it.
This can be useful for select tags where the options are 1 and 2.
Please send any complaints or opinions via Twitter DM.
That's all!
Please Provide Feedback
We would appreciate your feedback on this article. Feel free to leave a comment on any relevant YouTube video or reach out through the contact form. Thank you!