Bug Report #4016
Validation message for "matches" should say :param3 instead of :param2
| Status: | Feedback | Start date: | 05/23/2011 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 0% |
||
| Category: | Core | |||
| Target version: | - | |||
| Resolution: | invalid | Points: |
Description
Not sure if I did the pull request correctly, but the bug is just 1 char change:
https://github.com/kohana/core/pull/124
system/messages/validation.php
'matches' => ':field must be the same as :param2',
for
'matches' => ':field must be the same as :param3',
Thanks,
Nano.
Related issues
History
Updated by Woody Gilk 4 months ago
- Category set to Core
- Status changed from New to Closed
- Assignee set to Woody Gilk
- Resolution set to invalid
I'm 99% sure this is invalid. Please reopen if it is not.
Updated by Nano Documet 4 months ago
- Status changed from Closed to Feedback
You are correct, the original ticket is invalid. The issue is with the order of the fields in the rule definition:
1)
$validation = Validation::factory(array('foo' => 'foo'))
->rule('bar', 'matches', array(':validation', 'foo', ':field'));
outputs bar must be the same as foo
2)
$validation = Validation::factory(array('foo' => 'foo'))
->rule('bar', 'matches', array(':validation', 'foo', 'bar'));
outputs bar must be the same as foo
3)
$validation = Validation::factory(array('foo' => 'foo'))
->rule('bar', 'matches', array(':validation', 'bar', 'foo'));
outputs bar must be the same as bar
1 and 2 are the correct way. The Validation Test case has the right order https://github.com/kohana/core/blob/3.3/develop/tests/kohana/ValidationTest.php#L508
However, the example in the documentation shows the opposite order for the fields in the rule definition http://kohanaframework.org/3.2/guide/kohana/security/validation and the inline example in Validation https://github.com/kohana/core/blob/3.3/develop/classes/kohana/validation.php#L190 should have the order reversed too, should be $validation->rule('password', 'matches', array(':validation', 'password_repeat', 'password'));
Thus, I think the documentation/inline comments should have a note saying that the name of the other matching field should appear first, in addition to the right order of the fields.
Should I open another ticket for the documentation/inline comments or this one should be used?
Thanks.
Nano.
Updated by Ivan Brotkin 4 months ago
Agree with Nano Documet.
Kohana 3.0 has only a Validate class, so there was no need for passing Validation object into matches() rule. Since 3.1 we have 3 params, but message string wasnt changed.