Download the PHP package vjik/yii-validator-scenarios without Composer
On this page you can find all versions of the php package vjik/yii-validator-scenarios. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package yii-validator-scenarios
Yii Validator Scenarios
The package provides validator rule On that implement the scenario feature
for Yii Validator.
Requirements
- PHP 8.1 or higher.
Installation
The package could be installed with composer:
General usage
The scenario feature implement via the rule On and a validation context parameter.
Configure rules:
Or same without attributes:
Pass the scenario to the validator through the context:
Rules that will be applied according to scenarios:
register
| Attrubute | Rules |
|---|---|
name |
Required, Length |
email |
Required, Email |
password |
Required, Length |
login
| Attrubute | Rules |
|---|---|
name |
— |
email |
Required, Email |
password |
Required, Length |
Without scenario
| Attrubute | Rules |
|---|---|
name |
— |
email |
Required, Email |
password |
— |
On rule parameters
$scenario
The scenario(s) that $rules are in. null if rules used always. Defaults to null.
$rules
Rules that will be applied according to $scenario. Defaults to empty array.
$not
Whether the scenario check should be inverted. When this parameter is set true, the validator checks whether
the current scenario is among $scenario and if NOT, $rules will be applied. Defaults to false.
$skipOnEmpty
Whether skip $rules on empty value or not, and which value consider as empty. Defaults to null.
$skipOnError
A boolean value where true means to skip $rules when the previous one errored and false — do not skip.
Defaults to false.
$when
The closure that allow to apply $rules under certain conditions only. Defaults to null.
Testing
Unit testing
The package is tested with PHPUnit. To run tests:
Mutation testing
The package tests are checked with Infection mutation framework with Infection Static Analysis Plugin. To run it:
Static analysis
The code is statically analyzed with Psalm. To run static analysis:
License
The Yii Validator Scenarios is free software. It is released under the terms of the BSD License.
Please see LICENSE for more information.