Abstracts
1 year ago
Boolean.php
1 year ago
Currency.php
1 year ago
DateTime.php
1 year ago
Email.php
1 year ago
Exclude.php
1 year ago
ExcludeIf.php
1 year ago
ExcludeUnless.php
1 year ago
In.php
1 year ago
InStrict.php
1 year ago
Integer.php
1 year ago
Max.php
1 year ago
Min.php
1 year ago
Nullable.php
1 year ago
NullableIf.php
1 year ago
NullableUnless.php
1 year ago
Numeric.php
1 year ago
Optional.php
1 year ago
OptionalIf.php
1 year ago
OptionalUnless.php
1 year ago
Required.php
1 year ago
Size.php
1 year ago
InStrict.php
27 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Vendors\StellarWP\Validation\Rules; |
| 4 | |
| 5 | use Closure; |
| 6 | |
| 7 | class InStrict extends In |
| 8 | { |
| 9 | /** |
| 10 | * @since 1.2.0 |
| 11 | */ |
| 12 | public static function id(): string |
| 13 | { |
| 14 | return 'inStrict'; |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * @since 1.2.0 |
| 19 | */ |
| 20 | public function __invoke($value, Closure $fail, string $key, array $values) |
| 21 | { |
| 22 | if (!in_array($value, $this->acceptedValues, true)) { |
| 23 | $fail(sprintf(__('%s must be one of %s', 'give'), '{field}', implode(', ', $this->acceptedValues))); |
| 24 | } |
| 25 | } |
| 26 | } |
| 27 |