为什么 Laravel 抛出
InvalidArgumentException('The values under comparison must be of the same type');
异常(exception),当在规则上输入非数字文本(如“test”)时:
public function rules()
{
return [
'account_no' => 'required|numeric|gte:1'
];
}
当预期只是不通过验证并显示消息时:
account_no field must be numeric
如何解决这个异常?
最佳答案
Merdan下场gte
验证必须大于或等于给定的 field
.两人fields
必须是同一类型。
例如,假设您有两个字段
POST DATA
// $request->comparison = 1;
// $request->account_no = 20319312;
你的规则应该是这样的
return [
'account_no' => 'required|numeric|gte:comparison'
];
关于Laravel 验证数字与 gte :1 throws exception,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54801576/