mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-30 23:01:52 +00:00
Update README.md
This commit is contained in:
parent
c50b0186fc
commit
07866b56cc
@ -178,6 +178,7 @@ To add individual label to rule you simply add the `label` method after the rule
|
|||||||
$v = new Valitron\Validator(array());
|
$v = new Valitron\Validator(array());
|
||||||
$v->rule('required', 'name')->message('{field} is required')->label('Name');
|
$v->rule('required', 'name')->message('{field} is required')->label('Name');
|
||||||
$v->validate();
|
$v->validate();
|
||||||
|
```
|
||||||
|
|
||||||
There is a edge case to this method, you wouldn't be able to use a array of field names in the rule definition, so one rule per field. So this wouldn't work:
|
There is a edge case to this method, you wouldn't be able to use a array of field names in the rule definition, so one rule per field. So this wouldn't work:
|
||||||
|
|
||||||
@ -185,6 +186,7 @@ There is a edge case to this method, you wouldn't be able to use a array of fiel
|
|||||||
$v = new Valitron\Validator(array());
|
$v = new Valitron\Validator(array());
|
||||||
$v->rule('required', array('name', 'email'))->message('{field} is required')->label('Name');
|
$v->rule('required', array('name', 'email'))->message('{field} is required')->label('Name');
|
||||||
$v->validate();
|
$v->validate();
|
||||||
|
```
|
||||||
|
|
||||||
However we can use a array of labels to solve this issue by simply adding the `labels` method instead:
|
However we can use a array of labels to solve this issue by simply adding the `labels` method instead:
|
||||||
|
|
||||||
@ -196,6 +198,7 @@ $v->labels(array(
|
|||||||
'email' => 'Email address'
|
'email' => 'Email address'
|
||||||
));
|
));
|
||||||
$v->validate();
|
$v->validate();
|
||||||
|
```
|
||||||
|
|
||||||
This introduces a new set of tags to your error language file which looks like `{field}`, if you are using a rule like `equals` you can access the second value in the language file by incrementing the field with a value like `{field1}`.
|
This introduces a new set of tags to your error language file which looks like `{field}`, if you are using a rule like `equals` you can access the second value in the language file by incrementing the field with a value like `{field1}`.
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user