-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from programmatordev/1.x
v1.3.0
- Loading branch information
Showing
102 changed files
with
1,058 additions
and
397 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# AtLeastOneOf | ||
|
||
Checks that the value satisfies at least one of the given constraints. | ||
|
||
```php | ||
/** Validator[] $constraints */ | ||
Choice( | ||
array $constraints, | ||
?string $message = null | ||
); | ||
``` | ||
|
||
## Basic Usage | ||
|
||
```php | ||
Validator::atLeastOneOf([ | ||
Validator::isFalse(), | ||
Validator::type('int')->greaterThanOrEqual(18) | ||
])->validate(false); // true | ||
|
||
Validator::atLeastOneOf([ | ||
Validator::isFalse(), | ||
Validator::type('int')->greaterThanOrEqual(18) | ||
])->validate(20); // true | ||
|
||
Validator::atLeastOneOf([ | ||
Validator::isFalse(), | ||
Validator::type('int')->greaterThanOrEqual(18) | ||
])->validate(true); // false | ||
|
||
Validator::atLeastOneOf([ | ||
Validator::isFalse(), | ||
Validator::type('int')->greaterThanOrEqual(18) | ||
])->validate(16); // false | ||
``` | ||
|
||
> [!NOTE] | ||
> An `UnexpectedValueException` will be thrown when a value in the `constraints` array is not an instance of `Validator`. | ||
## Options | ||
|
||
### `constraints` | ||
|
||
type: `array<int, Validator>` `required` | ||
|
||
Collection of constraints to be validated against the input value. | ||
If at least one given constraint is valid, the validation is considered successful. | ||
|
||
### `message` | ||
|
||
type: `?string` default: `The {{ name }} value should satisfy at least one of the following constraints: {{ messages }}` | ||
|
||
Message that will be shown if all given constraints are not valid. | ||
|
||
The following parameters are available: | ||
|
||
| Parameter | Description | | ||
|------------------|-------------------------------------------------| | ||
| `{{ value }}` | The current invalid value | | ||
| `{{ name }}` | Name of the invalid value | | ||
| `{{ messages }}` | List of error messages based on the constraints | | ||
|
||
## Changelog | ||
|
||
- `1.3.0` Created |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# IsFalse | ||
|
||
Validates that a value is `false`. | ||
|
||
Check the [IsTrue](03-rules_is-true.md) rule for a `true` validation. | ||
|
||
```php | ||
IsFalse( | ||
?string $message = null | ||
); | ||
``` | ||
|
||
## Basic Usage | ||
|
||
```php | ||
// anything else will be false | ||
Validator::isFalse()->validate(false); // true | ||
``` | ||
|
||
## Options | ||
|
||
### `message` | ||
|
||
type: `?string` default: `The {{ name }} value should be false.` | ||
|
||
Message that will be shown if the value is false. | ||
|
||
The following parameters are available: | ||
|
||
| Parameter | Description | | ||
|---------------|---------------------------| | ||
| `{{ value }}` | The current invalid value | | ||
| `{{ name }}` | Name of the invalid value | | ||
|
||
## Changelog | ||
|
||
- `1.3.0` Created |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# IsNull | ||
|
||
Validates that a value is `null`. | ||
|
||
Check the [NotNull](03-rules_not-null.md) rule for the opposite validation. | ||
|
||
```php | ||
IsNull( | ||
?string $message = null | ||
); | ||
``` | ||
|
||
## Basic Usage | ||
|
||
```php | ||
// anything else will be false | ||
Validator::isNull()->validate(null); // true | ||
``` | ||
|
||
## Options | ||
|
||
### `message` | ||
|
||
type: `?string` default: `The {{ name }} value should be null.` | ||
|
||
Message that will be shown if the value is null. | ||
|
||
The following parameters are available: | ||
|
||
| Parameter | Description | | ||
|---------------|---------------------------| | ||
| `{{ value }}` | The current invalid value | | ||
| `{{ name }}` | Name of the invalid value | | ||
|
||
## Changelog | ||
|
||
- `1.3.0` Created |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# IsTrue | ||
|
||
Validates that a value is `true`. | ||
|
||
Check the [IsFalse](03-rules_is-false.md) rule for a `false` validation. | ||
|
||
```php | ||
IsTrue( | ||
?string $message = null | ||
); | ||
``` | ||
|
||
## Basic Usage | ||
|
||
```php | ||
// anything else will be false | ||
Validator::isTrue()->validate(true); // true | ||
``` | ||
|
||
## Options | ||
|
||
### `message` | ||
|
||
type: `?string` default: `The {{ name }} value should be true.` | ||
|
||
Message that will be shown if the value is true. | ||
|
||
The following parameters are available: | ||
|
||
| Parameter | Description | | ||
|---------------|---------------------------| | ||
| `{{ value }}` | The current invalid value | | ||
| `{{ name }}` | Name of the invalid value | | ||
|
||
## Changelog | ||
|
||
- `1.3.0` Created |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.