Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve eachValidator ? #16

Open
yoh opened this issue Sep 1, 2019 · 1 comment
Open

Improve eachValidator ? #16

yoh opened this issue Sep 1, 2019 · 1 comment
Assignees

Comments

@yoh
Copy link

yoh commented Sep 1, 2019

Hi ! Thank you for this lib !

Is there a way to combine eachValidator with FieldValidation and filters ?
Perhaps with something like this :

$v = Inhere\Validate\FieldValidation::check(['array' => [
    [
        'string' => "   some words    ",
        'int' => "44",
    ], [
        'string' => "   some letters    ",
        'int' => "   456  ",
    ]
]], [
    ['array.*.int', 'each|required|int', 'filter' => 'int'],
    ['array.*.string', 'each|required|string', 'filter' => 'trim'],
]);

Bonus question : is there a way to get index/key in the errors array ? Currently we don't know which element is/are in error ?

  0 => array:2 [▼
    "name" => "array.*.int"
    "msg" => "array.*.int must be through the int verify"
  ]
@inhere inhere self-assigned this Sep 2, 2019
@inhere
Copy link
Owner

inhere commented Apr 26, 2020

hi @yoh if use wildcard *, will skip apply filters. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants