我已经阅读了文档,我想知道是否可以根据规则和属性制作自定义消息,例如我有以下代码
$casoValidator = Validator::attribute('nombre',Validator::allOf(Validator::stringType(),Validator::notOptional(),
Validator::stringType()->length(3,100))) //nombre, validamos que sea cadena, que es obligatorio y que tiene de 3 a 100 caracteres
->attribute('idUsuario',Validator::allOf(Validator::intType()))
->attribute('numeroSertel',Validator::allOf(Validator::stringType(), Validator::stringType()->length(1,100)))
->attribute('dni',Validator::allOf(Validator::stringType(), Validator::stringType()->length(8,20))); //la capturaremos al hacer insert si hay problemas con las FK
try {
$asuntoValidator->assert($asunto);
} catch(NestedValidationException $exception) {
$errors = $exception->findMessages([
'length' => '{{name}} no puede tener mas de 100 caracteres ni menos de uno',
'notOptional' => '{{name}} no es opcional',
....
如您所见,“nombre”和“dni”的长度不同,所以我应该返回两条不同的消息,一条说你不能少于 3 个字符或超过 100 个字符,对于 dni,我应该返回 dni 可以'不少于 8 个字符,也不多于 20 个字符
有办法吗?