【发布时间】:2019-07-01 05:19:17
【问题描述】:
我一直在使用 required_without_all 作为 laravel 中至少一个必填字段。 这是我的规则代码
'rental_company_id' => 'required_without_all:camper_id,take_over_station_id,returnable_station_id',
'camper_id' => 'required_without_all:rental_company_id,take_over_station_id,returnable_station_id',
'take_over_station_id' => 'required_without_all:rental_company_id,camper_id,returnable_station_id',
'returnable_station_id' => 'required_without_all:rental_company_id,camper_id,take_over_station_id',
这是我的自定义消息,它将覆盖 laravel 生成的默认消息
'rental_company_id.required_without_all' => 'The Rental Companies is required when none of Campers, Takeover stations and Returnable stations are present.',
'camper_id.required_without_all' => 'The Campers is required when none of Rental Companies, Takeover stations and Returnable stations are present.',
'take_over_station_id.required_without_all' => 'The Takeover stations is required when none of Campers, Rental Companies and Returnable stations are present.',
'returnable_station_id.required_without_all' => 'The Returnable stations is required when none of Campers, Rental Companies and Takeover stations are present.',
而不是向用户显示多行错误消息。有什么办法可以把这四条消息总结成一条消息,比如
以下季节之一,租赁公司,...必须在场。
提前致谢。
【问题讨论】: