Skip to content

Commit a1f007e

Browse files
committed
Rename AllOf to LogicAnd
The name `AllOf` was ambiguous and could be confused with iteration semantics. The new name `LogicAnd` clearly indicates this is a logical `AND` operation where all provided rules must pass for the same input value. This rename is part of a broader effort to improve the naming of composite rules in version 3.0, making them more intuitive and reducing potential confusion when implementing validation logic.
1 parent 4cc45b5 commit a1f007e

34 files changed

Lines changed: 145 additions & 132 deletions

docs/concrete-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use Respect\Validation\Validators;
3939
$usernameValidator = ValidatorBuilder::init(
4040
new Validators\Key(
4141
'name',
42-
new Validators\AllOf(
42+
new Validators\LogicAnd(
4343
new Validators\Alnum(),
4444
new Validators\Not(
4545
new Validators\Spaced(),

docs/feature-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Respect\Validation offers over 150 validators, many of which are designed to add
4141
- Validating **Array structures**: [KeySet](validators/KeySet.md).
4242
- Validating **Object properties**: [Property](validators/Property.md), [PropertyOptional](validators/PropertyOptional.md), [PropertyExists](validators/PropertyExists.md).
4343
- Using **Conditional validation**: [NullOr](validators/NullOr.md), [UndefOr](validators/UndefOr.md), [When](validators/When.md).
44-
- Using **Grouped validation**: [AllOf](validators/AllOf.md), [AnyOf](validators/AnyOf.md), [NoneOf](validators/NoneOf.md), [OneOf](validators/OneOf.md)
44+
- Using **Logical validation**: [LogicAnd](validators/LogicAnd.md), [AnyOf](validators/AnyOf.md), [NoneOf](validators/NoneOf.md), [OneOf](validators/OneOf.md)
4545
- Validating **Each** value in the input: [Each](validators/Each.md).
4646
- Validating the **Length** of the input: [Length](validators/Length.md).
4747
- Validating the **Maximum** value in the input: [Max](validators/Max.md).

docs/list-of-validators-by-category.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@
5858

5959
## Composite
6060

61-
- [AllOf](validators/AllOf.md)
6261
- [AnyOf](validators/AnyOf.md)
6362
- [Circuit](validators/Circuit.md)
63+
- [LogicAnd](validators/LogicAnd.md)
6464
- [NoneOf](validators/NoneOf.md)
6565
- [OneOf](validators/OneOf.md)
6666

@@ -144,6 +144,10 @@
144144
- [PostalCode](validators/PostalCode.md)
145145
- [SubdivisionCode](validators/SubdivisionCode.md)
146146

147+
## Logical
148+
149+
- [LogicAnd](validators/LogicAnd.md)
150+
147151
## Math
148152

149153
- [Factor](validators/Factor.md)
@@ -167,14 +171,14 @@
167171

168172
## Nesting
169173

170-
- [AllOf](validators/AllOf.md)
171174
- [AnyOf](validators/AnyOf.md)
172175
- [Call](validators/Call.md)
173176
- [Circuit](validators/Circuit.md)
174177
- [Each](validators/Each.md)
175178
- [Key](validators/Key.md)
176179
- [KeySet](validators/KeySet.md)
177180
- [Lazy](validators/Lazy.md)
181+
- [LogicAnd](validators/LogicAnd.md)
178182
- [NoneOf](validators/NoneOf.md)
179183
- [Not](validators/Not.md)
180184
- [NullOr](validators/NullOr.md)
@@ -303,7 +307,6 @@
303307
## Alphabetically
304308

305309
- [All](validators/All.md)
306-
- [AllOf](validators/AllOf.md)
307310
- [Alnum](validators/Alnum.md)
308311
- [Alpha](validators/Alpha.md)
309312
- [AlwaysInvalid](validators/AlwaysInvalid.md)
@@ -392,6 +395,7 @@
392395
- [Length](validators/Length.md)
393396
- [LessThan](validators/LessThan.md)
394397
- [LessThanOrEqual](validators/LessThanOrEqual.md)
398+
- [LogicAnd](validators/LogicAnd.md)
395399
- [Lowercase](validators/Lowercase.md)
396400
- [Luhn](validators/Luhn.md)
397401
- [MacAddress](validators/MacAddress.md)

docs/validators/AnyOf.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ so `AnyOf()` returns true.
4444

4545
See also:
4646

47-
- [AllOf](AllOf.md)
4847
- [Circuit](Circuit.md)
4948
- [ContainsAny](ContainsAny.md)
49+
- [LogicAnd](LogicAnd.md)
5050
- [NoneOf](NoneOf.md)
5151
- [OneOf](OneOf.md)
5252
- [When](When.md)

docs/validators/Circuit.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ This validator does not have any templates, because it will always return the re
4040

4141
See also:
4242

43-
- [AllOf](AllOf.md)
4443
- [AnyOf](AnyOf.md)
4544
- [Lazy](Lazy.md)
45+
- [LogicAnd](LogicAnd.md)
4646
- [NoneOf](NoneOf.md)
4747
- [OneOf](OneOf.md)
4848
- [SubdivisionCode](SubdivisionCode.md)
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# AllOf
1+
# LogicAnd
22

3-
- `AllOf(Validator $validator1, Validator $validator2, Validator ...$validator)`
3+
- `LogicAnd(Validator $validator1, Validator $validator2, Validator ...$validator)`
44

5-
Will validate if all inner validators validates.
5+
Validates that all inner validators pass, acting as a logical `and` operator.
66

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

1111
## Templates
1212

13-
### `AllOf::TEMPLATE_SOME`
13+
### `LogicAnd::TEMPLATE_SOME`
1414

1515
Used when some validators must be failed.
1616

@@ -19,7 +19,7 @@ Used when some validators must be failed.
1919
| `default` | {{subject}} must pass the rules |
2020
| `inverted` | {{subject}} must pass the rules |
2121

22-
### `AllOf::TEMPLATE_ALL`
22+
### `LogicAnd::TEMPLATE_ALL`
2323

2424
Used when all validators have failed.
2525

@@ -37,14 +37,15 @@ Used when all validators have failed.
3737
## Categorization
3838

3939
- Composite
40+
- Logical
4041
- Nesting
4142

4243
## Changelog
4344

44-
| Version | Description |
45-
| ------: | -------------------------------------------- |
46-
| 3.0.0 | Require at least two validators to be passed |
47-
| 0.3.9 | Created |
45+
| Version | Description |
46+
| ------: | --------------------------------------------------------- |
47+
| 3.0.0 | Require at least two validators and renamed to `LogicAnd` |
48+
| 0.3.9 | Created as `AllOf` |
4849

4950
---
5051

docs/validators/NoneOf.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ Used when all validators have passed.
5555

5656
See also:
5757

58-
- [AllOf](AllOf.md)
5958
- [AnyOf](AnyOf.md)
6059
- [Circuit](Circuit.md)
60+
- [LogicAnd](LogicAnd.md)
6161
- [Not](Not.md)
6262
- [OneOf](OneOf.md)
6363
- [When](When.md)

docs/validators/OneOf.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ Used when more than one validator has passed.
5656

5757
See also:
5858

59-
- [AllOf](AllOf.md)
6059
- [AnyOf](AnyOf.md)
6160
- [Circuit](Circuit.md)
61+
- [LogicAnd](LogicAnd.md)
6262
- [NoneOf](NoneOf.md)
6363
- [When](When.md)

docs/validators/When.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ When `$else` is not defined use [AlwaysInvalid](AlwaysInvalid.md)
4444

4545
See also:
4646

47-
- [AllOf](AllOf.md)
4847
- [AlwaysInvalid](AlwaysInvalid.md)
4948
- [AnyOf](AnyOf.md)
5049
- [Circuit](Circuit.md)
50+
- [LogicAnd](LogicAnd.md)
5151
- [NoneOf](NoneOf.md)
5252
- [OneOf](OneOf.md)

library/Mixins/AllBuilder.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
interface AllBuilder
1616
{
17-
public static function allAllOf(Validator $validator1, Validator $validator2, Validator ...$validators): Chain;
18-
1917
public static function allAlnum(string ...$additionalChars): Chain;
2018

2119
public static function allAlpha(string ...$additionalChars): Chain;
@@ -195,6 +193,12 @@ public static function allLessThan(mixed $compareTo): Chain;
195193

196194
public static function allLessThanOrEqual(mixed $compareTo): Chain;
197195

196+
public static function allLogicAnd(
197+
Validator $validator1,
198+
Validator $validator2,
199+
Validator ...$validators,
200+
): Chain;
201+
198202
public static function allLowercase(): Chain;
199203

200204
public static function allLuhn(): Chain;

0 commit comments

Comments
 (0)