mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-30 23:01:52 +00:00
Always use custom label in place of field name
Fixes: https://github.com/vlucas/valitron/issues/32
This commit is contained in:
parent
247f6f3112
commit
d51f4c0fa5
@ -465,6 +465,10 @@ class Validator
|
||||
if($param instanceof \DateTime) {
|
||||
$param = $param->format('Y-m-d');
|
||||
}
|
||||
// Use custom label instead of field name if set
|
||||
if(isset($this->_labels[$param])) {
|
||||
$param = $this->_labels[$param];
|
||||
}
|
||||
$values[] = $param;
|
||||
}
|
||||
|
||||
|
||||
@ -545,6 +545,23 @@ class ValidateTest extends BaseTestCase
|
||||
), $v->errors());
|
||||
}
|
||||
|
||||
public function testCustomLabelArrayWithoutMessage()
|
||||
{
|
||||
$v = new Valitron\Validator(array(
|
||||
'password' => 'foo',
|
||||
'passwordConfirm' => 'bar'
|
||||
));
|
||||
$v->rule('equals', 'password', 'passwordConfirm');
|
||||
$v->labels(array(
|
||||
'password' => 'Password',
|
||||
'passwordConfirm' => 'Password Confirm'
|
||||
));
|
||||
$v->validate();
|
||||
$this->assertEquals(array(
|
||||
'password' => array("Password must be the same as 'Password Confirm'"),
|
||||
), $v->errors());
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom rules and callbacks
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user