class ValidationRuleParser (View source)

Properties

array $data

The data being validated.

array $implicitAttributes

The implicit attributes.

Methods

void
__construct(array $data)

Create a new validation rule parser.

explode(array $rules)

Parse the human-friendly rules into a full rules array for the validator.

array
explodeRules(array $rules)

Explode the rules into an array of explicit rules.

array
explodeExplicitRule(mixed $rule, string $attribute)

Explode the explicit rule into an array if necessary.

mixed
prepareRule(mixed $rule, string $attribute)

Prepare the given rule for the Validator.

array
explodeWildcardRules(array $results, string $attribute, string|array $rules)

Define a set of rules that apply to each element in an array attribute.

array
mergeRules(array $results, string|array $attribute, string|array $rules = [])

Merge additional rules into a given attribute(s).

array
mergeRulesForAttribute(array $results, string $attribute, string|array $rules)

Merge additional rules into a given attribute.

static array
parse(array|string $rule)

Extract the rule name and parameters from a rule.

static array
parseArrayRule(array $rule)

Parse an array based rule.

static array
parseStringRule(string $rule)

Parse a string based rule.

static array
parseParameters(string $rule, string $parameter)

Parse a parameter list.

static bool
ruleIsRegex(string $rule)

Determine if the rule is a regular expression.

static string
normalizeRule(string $rule)

Normalizes a rule so that we can accept short types.

static array
filterConditionalRules(array $rules, array $data = [])

Expand and conditional rules in the given array of rules.

Details

void __construct(array $data)

Create a new validation rule parser.

Parameters

array $data

Return Value

void

stdClass explode(array $rules)

Parse the human-friendly rules into a full rules array for the validator.

Parameters

array $rules

Return Value

stdClass

protected array explodeRules(array $rules)

Explode the rules into an array of explicit rules.

Parameters

array $rules

Return Value

array

protected array explodeExplicitRule(mixed $rule, string $attribute)

Explode the explicit rule into an array if necessary.

Parameters

mixed $rule
string $attribute

Return Value

array

protected mixed prepareRule(mixed $rule, string $attribute)

Prepare the given rule for the Validator.

Parameters

mixed $rule
string $attribute

Return Value

mixed

protected array explodeWildcardRules(array $results, string $attribute, string|array $rules)

Define a set of rules that apply to each element in an array attribute.

Parameters

array $results
string $attribute
string|array $rules

Return Value

array

array mergeRules(array $results, string|array $attribute, string|array $rules = [])

Merge additional rules into a given attribute(s).

Parameters

array $results
string|array $attribute
string|array $rules

Return Value

array

protected array mergeRulesForAttribute(array $results, string $attribute, string|array $rules)

Merge additional rules into a given attribute.

Parameters

array $results
string $attribute
string|array $rules

Return Value

array

static array parse(array|string $rule)

Extract the rule name and parameters from a rule.

Parameters

array|string $rule

Return Value

array

static protected array parseArrayRule(array $rule)

Parse an array based rule.

Parameters

array $rule

Return Value

array

static protected array parseStringRule(string $rule)

Parse a string based rule.

Parameters

string $rule

Return Value

array

static protected array parseParameters(string $rule, string $parameter)

Parse a parameter list.

Parameters

string $rule
string $parameter

Return Value

array

static protected bool ruleIsRegex(string $rule)

Determine if the rule is a regular expression.

Parameters

string $rule

Return Value

bool

static protected string normalizeRule(string $rule)

Normalizes a rule so that we can accept short types.

Parameters

string $rule

Return Value

string

static array filterConditionalRules(array $rules, array $data = [])

Expand and conditional rules in the given array of rules.

Parameters

array $rules
array $data

Return Value

array