'Laravel validation only allow one value for each field
I currently have a validation for sortField but I checked this accepts
/api/request?sortField='date'&sortField='time'
and I want it to only accept one value for the sortField so the above request should fail and throw an error. This can be nullable also.
public function rules()
{
return [
'sortField' => 'string',
];
}
Solution 1:[1]
- you need to as custom validation for one word
- you can check by following link :
https://blog.quickadminpanel.com/laravel-custom-validation-rule-max-word-count/
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Soham Virda |