ValidationRule.php
44 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @license GPL-2.0-or-later |
| 4 | * |
| 5 | * Modified by impress-org on 24-May-2023 using Strauss. |
| 6 | * @see https://github.com/BrianHenryIE/strauss |
| 7 | */ |
| 8 | |
| 9 | declare(strict_types=1); |
| 10 | |
| 11 | namespace Give\Vendors\StellarWP\Validation\Contracts; |
| 12 | |
| 13 | use Closure; |
| 14 | |
| 15 | interface ValidationRule |
| 16 | { |
| 17 | /** |
| 18 | * The unique id of the validation rule. |
| 19 | * |
| 20 | * @unreleased |
| 21 | */ |
| 22 | public static function id(): string; |
| 23 | |
| 24 | /** |
| 25 | * Creates a new instance of the validation rule from a string form. The string may be something like: |
| 26 | * "required" or "max:255". |
| 27 | * |
| 28 | * If a value is provided after the colon, it will be the options' parameter. |
| 29 | * |
| 30 | * @unreleased |
| 31 | */ |
| 32 | public static function fromString(string $options = null): ValidationRule; |
| 33 | |
| 34 | /** |
| 35 | * The invokable method used to validate the value. If the value is invalid, the fail callback should be invoked |
| 36 | * with the error message. Use {field} to reference the field name in the error message. |
| 37 | * |
| 38 | * @unreleased |
| 39 | * |
| 40 | * @return void |
| 41 | */ |
| 42 | public function __invoke($value, Closure $fail, string $key, array $values); |
| 43 | } |
| 44 |