ValidationRuleParser
class ValidationRuleParser
Properties
| array | $implicitAttributes | The implicit attributes. |
Methods
Create a new validation rule parser.
Parse the human-friendly rules into a full rules array for the validator.
Explode the rules into an array of explicit rules.
Explode the explicit rule into an array if necessary.
Prepare the given rule for the Validator.
Determine if the parser reduces a rule object to its string form.
Define a set of rules that apply to each element in an array attribute.
Explode wildcard rules that contain compilable rules.
Determine if a rules array contains any CompilableRules at any nesting level.
Merge additional rules into a given attribute(s).
Merge additional rules into a given attribute.
Extract the rule name and parameters from a rule.
Parse an array based rule.
Parse a parameter list.
Determine if the rule is a regular expression.
Normalizes a rule so that we can accept short types.
Determine if a rule argument names a field rather than stating a date literal.
Expand the conditional rules in the given array of rules.
Flush all static state.
Details
at line 41
__construct(array $data)
Create a new validation rule parser.
at line 49
stdClass
explode(array $rules)
Parse the human-friendly rules into a full rules array for the validator.
at line 64
protected array
explodeRules(array $rules)
Explode the rules into an array of explicit rules.
at line 83
protected array
explodeExplicitRule(mixed $rule, string $attribute)
Explode the explicit rule into an array if necessary.
at line 114
protected mixed
prepareRule(mixed $rule, string $attribute)
Prepare the given rule for the Validator.
at line 150
static bool
ruleReducesToString(mixed $rule)
Determine if the parser reduces a rule object to its string form.
at line 168
protected array
explodeWildcardRules(array $results, string $attribute, array|object|string $rules)
Define a set of rules that apply to each element in an array attribute.
Uses a direct tree walk instead of flattening the entire data array with Arr::dot() and regex matching. This is O(n) in the number of matching keys instead of O(n*m) where m is the total flattened key count.
at line 209
protected array
explodeWildcardRulesCompilable(array $results, string $attribute, array|object|string $rules)
Explode wildcard rules that contain compilable rules.
Compiled rules receive the flattened data, which the tree walk does not build.
at line 321
protected bool
containsCompilableRules(array $rules)
Determine if a rules array contains any CompilableRules at any nesting level.
Checks both top-level elements and elements inside nested arrays, so mixed rule arrays like ['nullable', Rule::forEach(...)] are detected.
at line 339
array
mergeRules(array $results, array|object|string $attribute, array|object|string $rules = [])
Merge additional rules into a given attribute(s).
at line 361
protected array
mergeRulesForAttribute(array $results, string $attribute, array|object|string $rules)
Merge additional rules into a given attribute.
at line 384
static array
parse(array|object|string $rule)
Extract the rule name and parameters from a rule.
at line 419
static protected array
parseArrayRule(array $rule)
Parse an array based rule.
at line 427
static protected array
parseStringRule(string|Stringable $rule)
Parse a string based rule.
at line 447
static protected array
parseParameters(string $rule, string $parameter)
Parse a parameter list.
at line 456
static protected bool
ruleIsRegex(string $rule)
Determine if the rule is a regular expression.
at line 464
static protected string
normalizeRule(string $rule)
Normalizes a rule so that we can accept short types.
at line 481
static bool
looksLikeDateFieldReference(mixed $argument)
Determine if a rule argument names a field rather than stating a date literal.
Behavioral callers must attempt literal parsing first. Compiler callers may conservatively delegate because false positives only select the full path.
at line 502
static array
filterConditionalRules(array $rules, array $data = [])
Expand the conditional rules in the given array of rules.
at line 530
static void
flushState()
Flush all static state.