验证命名选择选项输入类型名称[]乘以具有laravel版本5.6的验证选项吗?
根据文档,我试图以这种方式对其进行验证,但是它对我不起作用
一种方式
<select name="office[]">
$validator = Validator::make($request->all(), [
'office.*' => 'required'
], [
'office.required' => __('My message')
]);
Om que tampoco me funciona
$validator = Validator::make($request->all(), [
'office' => "required|array|min:1",
"office.*" => "required|integer|min:1",
], [
'office.*.required' => __('Debes agregar alguna sucursal')
]);
请帮忙!!!!
PS:我的版本是5.6。*
答案 0 :(得分:0)
对于复杂的数组,我将使用Custom Validation。这样一来,您就可以编写函数并根据需要通过验证。
extension Color {
init(hex: String) {
let scanner = Scanner(string: hex)
scanner.scanLocation = 0
var rgbValue: UInt64 = 0
scanner.scanHexInt64(&rgbValue)
let r = (rgbValue & 0xff0000) >> 16
let g = (rgbValue & 0xff00) >> 8
let b = rgbValue & 0xff
self.init(red: Double(r) / 0xff, green: Double(g) / 0xff, blue: Double(b) / 0xff)
}
}