base-validation-callback.php
3 years ago
is-user-email-unique.php
3 years ago
is-user-login-unique.php
3 years ago
rest-controller.php
3 years ago
rest-validation-endpoint.php
3 years ago
validation-callbacks.php
3 years ago
base-validation-callback.php
36 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Jet_Form_Builder\Blocks\Ssr_Validation; |
| 5 | |
| 6 | |
| 7 | use Jet_Form_Builder\Classes\Arrayable\Arrayable; |
| 8 | use Jet_Form_Builder\Classes\Repository\Repository_Item_Instance_Trait; |
| 9 | use Jet_Form_Builder\Request\Parser_Context; |
| 10 | |
| 11 | abstract class Base_Validation_Callback |
| 12 | implements Arrayable, Repository_Item_Instance_Trait { |
| 13 | |
| 14 | abstract public function get_id(): string; |
| 15 | |
| 16 | abstract public function get_label(): string; |
| 17 | |
| 18 | /** |
| 19 | * @param mixed $value |
| 20 | * |
| 21 | * @return bool |
| 22 | */ |
| 23 | abstract public function is_valid( $value, Parser_Context $context ): bool; |
| 24 | |
| 25 | public function to_array(): array { |
| 26 | return array( |
| 27 | 'value' => $this->get_id(), |
| 28 | 'label' => $this->get_label(), |
| 29 | ); |
| 30 | } |
| 31 | |
| 32 | public function rep_item_id() { |
| 33 | return $this->get_id(); |
| 34 | } |
| 35 | |
| 36 | } |