99use Brick \Math \BigNumber ;
1010use DateTimeInterface ;
1111use Illuminate \Contracts \Support \Arrayable ;
12- use Illuminate \Contracts \Validation \InvokableRule ;
13- use Illuminate \Contracts \Validation \Rule as RuleContract ;
14- use Illuminate \Contracts \Validation \ValidationRule ;
15- use Illuminate \Validation \ConditionalRules ;
1612use Illuminate \Validation \Rules \Password ;
1713use Illuminate \Validation \Rules \RequiredIf ;
1814use IteratorAggregate ;
19- use Stringable ;
2015use UnitEnum ;
2116
2217/**
23- * @implements Arrayable<array-key, RuleContract|InvokableRule|ValidationRule|ConditionalRules|Stringable|string>
24- * @implements IteratorAggregate<array-key, RuleContract|InvokableRule|ValidationRule|ConditionalRules|Stringable|string>
18+ * @phpstan-import-type RuleType from Rule
19+ * @phpstan-import-type RuleSetDefinition from Rule
20+ * @implements Arrayable<array-key, RuleType>
21+ * @implements IteratorAggregate<array-key, RuleType>
2522 */
2623class RuleSet implements Arrayable, IteratorAggregate
2724{
2825 /**
29- * @param array<array-key, RuleContract|InvokableRule|ValidationRule|ConditionalRules|Stringable|string > $rules
26+ * @param array<array-key, RuleType > $rules
3027 */
3128 final public function __construct (protected array $ rules = [])
3229 {
3330 //
3431 }
3532
3633 /**
37- * @return ArrayIterator<array-key, RuleContract|InvokableRule|ValidationRule|ConditionalRules|Stringable|string >
34+ * @return ArrayIterator<array-key, RuleType >
3835 */
3936 public function getIterator (): ArrayIterator
4037 {
@@ -44,7 +41,7 @@ public function getIterator(): ArrayIterator
4441 /**
4542 * Get the rule set as an array.
4643 *
47- * @return array<array-key, RuleContract|InvokableRule|ValidationRule|ConditionalRules|Stringable|string >
44+ * @return array<array-key, RuleType >
4845 */
4946 public function toArray (): array
5047 {
@@ -54,7 +51,7 @@ public function toArray(): array
5451 /**
5552 * Create a new rule set.
5653 *
57- * @param array<array-key, RuleContract|InvokableRule|ValidationRule|ConditionalRules|Stringable|string > $rules
54+ * @param array<array-key, RuleType > $rules
5855 */
5956 public static function create (array $ rules = []): self
6057 {
@@ -80,7 +77,7 @@ public static function useDefined(string|BackedEnum|UnitEnum $name): RuleSet
8077 /**
8178 * Append one or more rules to the end of the rule set.
8279 *
83- * @param RuleContract|InvokableRule|ValidationRule|ConditionalRules|Stringable|string $rule
80+ * @param RuleType $rule
8481 */
8582 public function concat (...$ rule ): self
8683 {
@@ -98,7 +95,7 @@ public function concatDefined(string $name): self
9895 /**
9996 * Append a rule to the end of the rule set.
10097 *
101- * @param RuleContract|InvokableRule|ValidationRule|ConditionalRules|Stringable|string $rule
98+ * @param RuleType $rule
10299 */
103100 public function rule (mixed $ rule ): self
104101 {
@@ -205,6 +202,18 @@ public function alphaNum(?bool $limitToAscii = null): self
205202 return $ this ->rule (Rule::alphaNum ($ limitToAscii ));
206203 }
207204
205+ /**
206+ * The `anyOf` validation rule allows you to specify that the field under validation must satisfy any of the given
207+ * validation rulesets.
208+ *
209+ * @link https://laravel.com/docs/12.x/validation#rule-anyof
210+ * @param array<array-key, RuleSetDefinition> $ruleSets
211+ */
212+ public function anyOf (array $ ruleSets ): self
213+ {
214+ return $ this ->rule (Rule::anyOf ($ ruleSets ));
215+ }
216+
208217 /**
209218 * The field under validation must be a PHP *array*.
210219 *
@@ -759,6 +768,16 @@ public function inArray(string $anotherField): self
759768 return $ this ->rule (Rule::inArray ($ anotherField ));
760769 }
761770
771+ /**
772+ * The field under validation must be an array having at least one of the given *values* as a key within the array.
773+ *
774+ * @link https://laravel.com/docs/12.x/validation#rule-in-array-keys
775+ */
776+ public function inArrayKeys (string ...$ value ): self
777+ {
778+ return $ this ->rule (Rule::inArrayKeys (...$ value ));
779+ }
780+
762781 /**
763782 * The field under validation must be an integer.
764783 *
@@ -1505,8 +1524,8 @@ public function uuid(): self
15051524 * Create a new conditional rule set.
15061525 *
15071526 * @param bool|callable(\Illuminate\Support\Fluent<array-key, mixed>): bool $condition
1508- * @param array<array-key, RuleContract|InvokableRule|ValidationRule|ConditionalRules|Stringable|string >|string|RuleSet $rules
1509- * @param array<array-key, RuleContract|InvokableRule|ValidationRule|ConditionalRules|Stringable|string >|string|RuleSet $defaultRules
1527+ * @param array<array-key, RuleType >|string|RuleSet $rules
1528+ * @param array<array-key, RuleType >|string|RuleSet $defaultRules
15101529 */
15111530 public function when (mixed $ condition , array |string |RuleSet $ rules , array |string |RuleSet $ defaultRules = []): self
15121531 {
0 commit comments