Laravel验证仅允许每个字段一个值
我目前对Sortfield有验证,但我检查了此convects
/api /request?stortfield ='date'& stortfield ='time'
,我希望它仅接受sortfield的一个值,以便上述请求应失败并投掷一个错误。这也可以无效。
public function rules()
{
return [
'sortField' => 'string',
];
}
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',
];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
https://blog.quickadminpanel.com/laravel-custom-validation-rule-max-word-count/
https://blog.quickadminpanel.com/laravel-custom-validation-rule-max-word-count/