-
<?php
use Respect\Validation\Validator as v;
use Respect\Validation\Exceptions\ValidationException;
$data = [
'user' => [
'name' => 'this is a too long name for a user',
]
];
try {
v::key('user', v::key('name', v::stringType()->length(1, 30)))->check($data);
} catch (ValidationException $e) {
var_dump($e->getId()); // name
} In the exception it returns |
Beta Was this translation helpful? Give feedback.
Answered by
berrymore
Dec 17, 2024
Replies: 1 comment 4 replies
-
// ...
try {
v::allOf(
v::keyNested('user.name', v::stringType()->length(1, 30))
)->check($data);
} catch (ValidationException $e) {
var_dump($e->getId()); // user.name
} As a workaround, I use this solution |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
henriquemoody
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As a workaround, I use this solution