ArrayRule.php
2 weeks ago
BooleanRule.php
2 weeks ago
ConditionalRule.php
2 weeks ago
DateRule.php
2 weeks ago
ExistsRule.php
2 weeks ago
FileRule.php
2 weeks ago
InRule.php
2 weeks ago
NotInRule.php
2 weeks ago
NullableRule.php
2 weeks ago
NumericRule.php
2 weeks ago
ObjectRule.php
2 weeks ago
ProhibitedIfRule.php
2 weeks ago
ProhibitedRule.php
2 weeks ago
ProhibitedUnlessRule.php
2 weeks ago
RequiredIfRule.php
2 weeks ago
RequiredRule.php
2 weeks ago
RequiredUnlessRule.php
2 weeks ago
SameAsRule.php
2 weeks ago
SometimesRule.php
2 weeks ago
StringRule.php
2 weeks ago
UniqueRule.php
2 weeks ago
InRule.php
50 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * In 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 | class InRule extends ValidationRule |
| 15 | { |
| 16 | /** |
| 17 | * The rule name. |
| 18 | * |
| 19 | * @var string |
| 20 | * |
| 21 | * @since 1.0.0 |
| 22 | */ |
| 23 | protected string $rule = 'in'; |
| 24 | /** |
| 25 | * Validate the rule. |
| 26 | * |
| 27 | * @return bool |
| 28 | * |
| 29 | * @since 1.0.0 |
| 30 | */ |
| 31 | public function validate() : bool |
| 32 | { |
| 33 | if (!\in_array($this->value, $this->args)) { |
| 34 | return $this->fails($this->default_messages['default']); |
| 35 | } |
| 36 | return \true; |
| 37 | } |
| 38 | /** |
| 39 | * Get the error message. |
| 40 | * |
| 41 | * @return string |
| 42 | * |
| 43 | * @since 1.0.0 |
| 44 | */ |
| 45 | public function messages() |
| 46 | { |
| 47 | return $this->process_messages($this->messages); |
| 48 | } |
| 49 | } |
| 50 |