Validation
- Full name:
\Qubus\Validation\Validation
Properties
validator
inputs
attributes
aliases
messageSeparator
validData
invalidData
errors
Methods
__construct
public __construct(\Qubus\Validation\Validator $validator, array $inputs, array $rules, array $messages = []): void
Parameters:
| Parameter | Type | Description |
|---|---|---|
$validator | \Qubus\Validation\Validator | |
$inputs | array | |
$rules | array | |
$messages | array |
Throws:
addAttribute
Add attribute rules.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$attributeKey | string | |
$rules | array|string |
Throws:
getAttribute
Get attribute by key.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$attributeKey | string |
validate
Run validation.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$inputs | array |
Throws:
errors
Get ErrorBag instance.
validateAttribute
Validate attribute.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$attribute | \Qubus\Validation\Attribute |
Throws:
isArrayAttribute
Check whether given $attribute is array attribute.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$attribute | \Qubus\Validation\Attribute |
parseArrayAttribute
Parse array attribute into it's child attributes.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$attribute | \Qubus\Validation\Attribute |
Throws:
initializeAttributeOnData
Gather a copy of the attribute data filled with any missing attributes.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$attributeKey | string |
Throws:
extractValuesForWildcards
Get all the exact attribute values for a given wildcard attribute.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$data | array | |
$attributeKey | string |
Throws:
getLeadingExplicitAttributePath
Get the explicit part of the attribute name.
E.g. 'foo.bar.*.baz' -> 'foo.bar'
Allows us to not spin through all the flattened data for some operations.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$attributeKey | string |
Return Value:
null when root wildcard
extractDataFromPath
Extract data based on the given dot-notated path.
Used to extract a subsection of the data for faster iteration.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$attributeKey | string|null |
Throws:
addError
Add error to the $this->errors.
protected addError(\Qubus\Validation\Attribute $attribute, mixed $value, \Qubus\Validation\Rule $ruleValidator): void
Parameters:
| Parameter | Type | Description |
|---|---|---|
$attribute | \Qubus\Validation\Attribute | |
$value | mixed | |
$ruleValidator | \Qubus\Validation\Rule |
isEmptyValue
Check $value is empty value.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$value | mixed |
ruleIsOptional
Check the rule is optional.
protected ruleIsOptional(\Qubus\Validation\Attribute $attribute, \Qubus\Validation\Rule $rule): bool
Parameters:
| Parameter | Type | Description |
|---|---|---|
$attribute | \Qubus\Validation\Attribute | |
$rule | \Qubus\Validation\Rule |
resolveAttributeName
Resolve attribute name.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$attribute | \Qubus\Validation\Attribute |
resolveMessage
Resolve message.
protected resolveMessage(\Qubus\Validation\Attribute $attribute, mixed $value, \Qubus\Validation\Rule $validator): mixed
Parameters:
| Parameter | Type | Description |
|---|---|---|
$attribute | \Qubus\Validation\Attribute | |
$value | mixed | |
$validator | \Qubus\Validation\Rule |
stringify
Stringify $value.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$value | mixed |
resolveRules
Resolve $rules.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$rules | mixed |
Throws:
parseRule
Parse $rule.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$rule | string |
setAlias
Given $attributeKey and $alias then assign alias.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$attributeKey | mixed | |
$alias | mixed |
getAlias
Get attribute alias from given key.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$attributeKey | mixed |
setAliases
Set attributes aliases.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$aliases | array |
passes
Check validations are passed.
fails
Check validations are failed.
getValue
Given $key and get value.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$key | string |
Throws:
setValue
Set input value.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$key | string | |
$value | mixed |
hasValue
Given $key and check value exists.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$key | string |
getValidator
Get Validator class instance.
resolveInputAttributes
Given $inputs and resolve input attributes.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$inputs | array |
getValidatedData
Get validated data.
setValidData
Set valid data.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$attribute | \Qubus\Validation\Attribute | |
$value | mixed |
getValidData
Get valid data.
setInvalidData
Set invalid data.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$attribute | \Qubus\Validation\Attribute | |
$value | mixed |
getInvalidData
Get invalid data.
Inherited methods
setMessage
Given $key and $message to set message.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$key | mixed | |
$message | mixed |
setMessages
Given $messages and set multiple messages.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$messages | array |
getMessage
Given message from given $key.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$key | string |
getMessages
Get all $messages
setTranslation
Given $key and $translation to set translation
Parameters:
| Parameter | Type | Description |
|---|---|---|
$key | mixed | |
$translation | mixed |
setTranslations
Given $translations and set multiple translations
Parameters:
| Parameter | Type | Description |
|---|---|---|
$translations | array |
getTranslation
Given translation from given $key
Parameters:
| Parameter | Type | Description |
|---|---|---|
$key | string |
getTranslations
Get all $translations