| 1 | <?php |
||
| 16 | trait When |
||
| 17 | { |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Set this to string - to check if property value is trueish: |
||
| 21 | * |
||
| 22 | * ``` |
||
| 23 | * $when = 'myProperty'; |
||
| 24 | * ``` |
||
| 25 | * |
||
| 26 | * This will check if property value is not `false` and validate |
||
| 27 | * only if this property is trueish. |
||
| 28 | * |
||
| 29 | * Set this to array to check specified criteria: |
||
| 30 | * |
||
| 31 | * ``` |
||
| 32 | * $when = [ |
||
| 33 | * 'firstProperty' => 1, |
||
| 34 | * 'secondProperty' => true |
||
| 35 | * ]; |
||
| 36 | * ``` |
||
| 37 | * |
||
| 38 | * Will run validation only when those values of model properties |
||
| 39 | * are exact as provided. |
||
| 40 | * |
||
| 41 | * @var string|array |
||
| 42 | */ |
||
| 43 | public $when = null; |
||
| 44 | |||
| 45 | 36 | public function whenValidate($model) |
|
| 70 | |||
| 71 | } |
||
| 72 |