mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-30 23:01:52 +00:00
Changed method name for readability and writting some docs.
This commit is contained in:
parent
6a6810e25c
commit
bfa24585de
27
README.md
27
README.md
@ -127,6 +127,33 @@ V::lang('ar');
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Disabling the {field} name in the output of the error message.
|
||||||
|
|
||||||
|
```php
|
||||||
|
use Valitron\Validator as V;
|
||||||
|
|
||||||
|
$v = new Valitron\Validator(['name' => 'John']);
|
||||||
|
$v->rule('required', ['name']);
|
||||||
|
|
||||||
|
// Disable prepending the labels
|
||||||
|
$v->setPrependLabels(false);
|
||||||
|
|
||||||
|
// Error output for the "false" condition
|
||||||
|
[
|
||||||
|
["name"] => [
|
||||||
|
"is required"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
// Error output for the default (true) condition
|
||||||
|
[
|
||||||
|
["name"] => [
|
||||||
|
"name is required"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
You can conditionally require values using required conditional rules. In this example, for authentication, we're requiring either a token when both the email and password are not present, or a password when the email address is present.
|
You can conditionally require values using required conditional rules. In this example, for authentication, we're requiring either a token when both the email and password are not present, or a password when the email address is present.
|
||||||
```php
|
```php
|
||||||
// this rule set would work for either data set...
|
// this rule set would work for either data set...
|
||||||
|
|||||||
@ -152,7 +152,7 @@ class Validator
|
|||||||
/**
|
/**
|
||||||
* @param bool $prepend_labels
|
* @param bool $prepend_labels
|
||||||
*/
|
*/
|
||||||
public function prependLabels($prepend_labels = true)
|
public function setPrependLabels($prepend_labels = true)
|
||||||
{
|
{
|
||||||
$this->prepend_labels = $prepend_labels;
|
$this->prepend_labels = $prepend_labels;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user