Skip to content

Commit 061a3c9

Browse files
committed
Rename method "validate()" to "isValid()"
The method has been renamed some time ago, but I haven't updated the documentation to cause less confusion. Now that I want to start updating the documentation, I switched the default branch on GitHub to the latest stable version, so I assume there will be less confusion in the documentation, and I can start updating the docs for the next version.
1 parent b894593 commit 061a3c9

File tree

163 files changed

+558
-558
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+558
-558
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
The most awesome validation engine ever created for PHP.
1010

11-
- Complex rules made simple: `v::numericVal()->positive()->between(1, 255)->validate($input)`.
11+
- Complex rules made simple: `v::numericVal()->positive()->between(1, 255)->isValid($input)`.
1212
- [Granularity control](docs/02-feature-guide.md#validation-methods) for advanced reporting.
1313
- [More than 150](docs/08-list-of-rules-by-category.md) (fully tested) validation rules.
1414
- [A concrete API](docs/05-concrete-api.md) for non fluent usage.

docs/02-feature-guide.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The Hello World validator is something like this:
1515

1616
```php
1717
$number = 123;
18-
v::numericVal()->validate($number); // true
18+
v::numericVal()->isValid($number); // true
1919
```
2020

2121
## Chained validation
@@ -25,7 +25,7 @@ containing numbers and letters, no whitespace and length between 1 and 15.
2525

2626
```php
2727
$usernameValidator = v::alnum()->noWhitespace()->length(1, 15);
28-
$usernameValidator->validate('alganet'); // true
28+
$usernameValidator->isValid('alganet'); // true
2929
```
3030

3131
## Validating object properties
@@ -44,7 +44,7 @@ Is possible to validate its properties in a single chain:
4444
$userValidator = v::property('name', v::stringType()->length(1, 32))
4545
->property('birthdate', v::dateTimeDiff(v::greaterThanOrEqual(18), 'years'));
4646

47-
$userValidator->validate($user); // true
47+
$userValidator->isValid($user); // true
4848
```
4949

5050
Validating array keys is also possible using `v::key()`
@@ -93,11 +93,11 @@ For that reason all rules are mandatory now but if you want to treat a value as
9393
optional you can use `v::optional()` rule:
9494

9595
```php
96-
v::alpha()->validate(''); // false input required
97-
v::alpha()->validate(null); // false input required
96+
v::alpha()->isValid(''); // false input required
97+
v::alpha()->isValid(null); // false input required
9898

99-
v::optional(v::alpha())->validate(''); // true
100-
v::optional(v::alpha())->validate(null); // true
99+
v::optional(v::alpha())->isValid(''); // true
100+
v::optional(v::alpha())->isValid(null); // true
101101
```
102102

103103
By _optional_ we consider `null` or an empty string (`''`).
@@ -109,17 +109,17 @@ See more on [Optional](rules/UndefOr.md).
109109
You can use the `v::not()` to negate any rule:
110110

111111
```php
112-
v::not(v::intVal())->validate(10); // false, input must not be integer
112+
v::not(v::intVal())->isValid(10); // false, input must not be integer
113113
```
114114

115115
## Validator reuse
116116

117117
Once created, you can reuse your validator anywhere. Remember `$usernameValidator`?
118118

119119
```php
120-
$usernameValidator->validate('respect'); //true
121-
$usernameValidator->validate('alexandre gaigalas'); // false
122-
$usernameValidator->validate('#$%'); //false
120+
$usernameValidator->isValid('respect'); //true
121+
$usernameValidator->isValid('alexandre gaigalas'); // false
122+
$usernameValidator->isValid('#$%'); //false
123123
```
124124

125125
## Exception types

docs/05-concrete-api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ or magic methods. We'll use a traditional dependency injection approach.
88
use Respect\Validation\Validator as v;
99

1010
$usernameValidator = v::alnum()->noWhitespace()->length(1, 15);
11-
$usernameValidator->validate('alganet'); // true
11+
$usernameValidator->isValid('alganet'); // true
1212
```
1313

1414
If you `var_dump($usernameValidator)`, you'll see a composite of objects with
@@ -24,7 +24,7 @@ $usernameValidator = new Rules\AllOf(
2424
new Rules\NoWhitespace(),
2525
new Rules\Length(1, 15)
2626
);
27-
$usernameValidator->validate('alganet'); // true
27+
$usernameValidator->isValid('alganet'); // true
2828
```
2929

3030
This is still a very lean API. You can use it in any dependency injection
@@ -39,7 +39,7 @@ $usernameValidator = new Rules\AllOf(
3939
new Rules\Length(1, 15)
4040
);
4141
$userValidator = new Rules\Key('name', $usernameValidator);
42-
$userValidator->validate(['name' => 'alganet']); // true
42+
$userValidator->isValid(['name' => 'alganet']); // true
4343
```
4444

4545
## How It Works?

docs/07-comparable-values.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ that can be parsed by PHP
1616
Below you can see some examples:
1717

1818
```php
19-
v::greaterThanOrEqual(100)->validate($collection); // true if it has at least 100 items
19+
v::greaterThanOrEqual(100)->isValid($collection); // true if it has at least 100 items
2020

2121
v::dateTime()
2222
->between(new DateTime('yesterday'), new DateTime('tomorrow'))
23-
->validate(new DateTime('now')); // true
23+
->isValid(new DateTime('now')); // true
2424

25-
v::numericVal()->lessThanOrEqual(10)->validate(5); // true
25+
v::numericVal()->lessThanOrEqual(10)->isValid(5); // true
2626

27-
v::stringVal()->between('a', 'f')->validate('d'); // true
27+
v::stringVal()->between('a', 'f')->isValid('d'); // true
2828

29-
v::dateTime()->between('yesterday', 'tomorrow')->validate('now'); // true
29+
v::dateTime()->between('yesterday', 'tomorrow')->isValid('now'); // true
3030
```

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The most awesome validation engine ever created for PHP.
44

5-
- Complex rules made simple: `v::numericVal()->positive()->between(1, 255)->validate($input)`.
5+
- Complex rules made simple: `v::numericVal()->positive()->between(1, 255)->isValid($input)`.
66
- [Granularity control](02-feature-guide.md#validation-methods) for advanced reporting.
77
- [More than 150](08-list-of-rules-by-category.md) (fully tested) validation rules.
88
- [A concrete API](05-concrete-api.md) for non fluent usage.

docs/rules/AllOf.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Will validate if all inner validators validates.
66

77
```php
8-
v::allOf(v::intVal(), v::positive())->validate(15); // true
8+
v::allOf(v::intVal(), v::positive())->isValid(15); // true
99
```
1010

1111
## Categorization

docs/rules/Alnum.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ Alphanumeric is a combination of alphabetic (a-z and A-Z) and numeric (0-9)
99
characters.
1010

1111
```php
12-
v::alnum()->validate('foo 123'); // false
13-
v::alnum(' ')->validate('foo 123'); // true
14-
v::alnum()->validate('100%'); // false
15-
v::alnum('%')->validate('100%'); // true
16-
v::alnum('%', ',')->validate('10,5%'); // true
12+
v::alnum()->isValid('foo 123'); // false
13+
v::alnum(' ')->isValid('foo 123'); // true
14+
v::alnum()->isValid('100%'); // false
15+
v::alnum('%')->isValid('100%'); // true
16+
v::alnum('%', ',')->isValid('10,5%'); // true
1717
```
1818

1919
You can restrict case using the [Lowercase](Lowercase.md) and
2020
[Uppercase](Uppercase.md) rules.
2121

2222
```php
23-
v::alnum()->uppercase()->validate('example'); // false
23+
v::alnum()->uppercase()->isValid('example'); // false
2424
```
2525

2626
Message template for this validator includes `{{additionalChars}}` as the string

docs/rules/Alpha.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ Validates whether the input contains only alphabetic characters. This is similar
77
to [Alnum](Alnum.md), but it does not allow numbers.
88

99
```php
10-
v::alpha()->validate('some name'); // false
11-
v::alpha(' ')->validate('some name'); // true
12-
v::alpha()->validate('Cedric-Fabian'); // false
13-
v::alpha('-')->validate('Cedric-Fabian'); // true
14-
v::alpha('-', '\'')->validate('\'s-Gravenhage'); // true
10+
v::alpha()->isValid('some name'); // false
11+
v::alpha(' ')->isValid('some name'); // true
12+
v::alpha()->isValid('Cedric-Fabian'); // false
13+
v::alpha('-')->isValid('Cedric-Fabian'); // true
14+
v::alpha('-', '\'')->isValid('\'s-Gravenhage'); // true
1515
```
1616

1717
You can restrict case using the [Lowercase](Lowercase.md) and
1818
[Uppercase](Uppercase.md) rules.
1919

2020
```php
21-
v::alpha()->uppercase()->validate('example'); // false
21+
v::alpha()->uppercase()->isValid('example'); // false
2222
```
2323

2424
## Categorization

docs/rules/AlwaysInvalid.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Validates any input as invalid.
66

77
```php
8-
v::alwaysInvalid()->validate('whatever'); // false
8+
v::alwaysInvalid()->isValid('whatever'); // false
99
```
1010

1111
## Categorization

docs/rules/AlwaysValid.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Validates any input as valid.
66

77
```php
8-
v::alwaysValid()->validate('whatever'); // true
8+
v::alwaysValid()->isValid('whatever'); // true
99
```
1010

1111
## Categorization

0 commit comments

Comments
 (0)