ArrayRule.php
1 week ago
BooleanRule.php
1 week ago
ConditionalRule.php
1 week ago
DateRule.php
1 week ago
ExistsRule.php
1 week ago
FileRule.php
1 week ago
InRule.php
1 week ago
NotInRule.php
1 week ago
NullableRule.php
1 week ago
NumericRule.php
1 week ago
ObjectRule.php
1 week ago
ProhibitedIfRule.php
1 week ago
ProhibitedRule.php
1 week ago
ProhibitedUnlessRule.php
1 week ago
RequiredIfRule.php
1 week ago
RequiredRule.php
1 week ago
RequiredUnlessRule.php
1 week ago
SameAsRule.php
1 week ago
SometimesRule.php
1 week ago
StringRule.php
1 week ago
UniqueRule.php
1 week ago
ProhibitedRule.php
61 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Prohibited rule class. |
| 5 | * |
| 6 | * @package Framework |
| 7 | * @subpackage Validation |
| 8 | * @since 1.0.0 |
| 9 | */ |
| 10 | namespace Kirki\Framework\Validation\Rules; |
| 11 | |
| 12 | use Kirki\Framework\Validation\ValidationRule; |
| 13 | \defined('ABSPATH') || exit; |
| 14 | /** |
| 15 | * Validates that the given field is absent or empty. |
| 16 | */ |
| 17 | class ProhibitedRule extends ValidationRule |
| 18 | { |
| 19 | /** |
| 20 | * The rule name. |
| 21 | * |
| 22 | * @var string |
| 23 | * |
| 24 | * @since 1.0.0 |
| 25 | */ |
| 26 | protected string $rule = 'prohibited'; |
| 27 | /** |
| 28 | * Whether the rule is an implicit rule. |
| 29 | * |
| 30 | * @var bool |
| 31 | * |
| 32 | * @since 1.0.0 |
| 33 | */ |
| 34 | public bool $is_implicit = \true; |
| 35 | /** |
| 36 | * Validate the rule. |
| 37 | * |
| 38 | * @return bool |
| 39 | * |
| 40 | * @since 1.0.0 |
| 41 | */ |
| 42 | public function validate() : bool |
| 43 | { |
| 44 | if (static::is_nullish($this->value)) { |
| 45 | return \true; |
| 46 | } |
| 47 | return $this->fails($this->default_messages['default']); |
| 48 | } |
| 49 | /** |
| 50 | * Get the error messages. |
| 51 | * |
| 52 | * @return array |
| 53 | * |
| 54 | * @since 1.0.0 |
| 55 | */ |
| 56 | public function messages() |
| 57 | { |
| 58 | return $this->process_messages($this->messages); |
| 59 | } |
| 60 | } |
| 61 |