Validation: setName doesn't work for attribute
Hi guys. I have some troubles with setName and attributes. My code looks like this:
$validator = v::attribute('email', v::notEmpty()->email())->setName('Email Field')
->attribute('password', v::notEmpty()->noWhitespace())->setName('Password Field');
$this->validator->assert($entity);
$errors = $ex->findMessages([
'email' => 'Error: {{name}}',
'notEmpty' => 'Error: {{name}}',
'noWhitespace' => 'Error: {{name}}'
]);
I’ve expected to see error
Error: Email Field Error: Password Field
But I’ve got
Error: email Error: password
Why so? How I can set name for attribute correctly? Thank you.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 15 (7 by maintainers)
Commits related to this issue
- Added test for issue #620 — committed to auburus/Validation by auburus 8 years ago
This bug was finally fixed on versions 1.0.11 and 1.1.6 by #675.
I’m very sorry about my delay (I talked about that already https://github.com/Respect/Validation/issues/620#issuecomment-237474435).
Thanks for reporting! 🐼
Unfortunately the
AttributeSetrule won’t fix the problem, but it’s a nice idea. Can you create a issue for that, @batusa?This still doesn’t work:
Result:
Array ( [0] => email must be valid email )Thanks. 😃