DataValidator
in package
Table of Contents
Properties
- $data : array<string|int, mixed>
- $errors : array<string|int, mixed>
- $rules : array<string|int, mixed>
- $sanitizedData : array<string|int, mixed>
Methods
- getErrors() : array<string|int, mixed>
- Returns the errors
- getRawData() : array<string|int, mixed>
- Returns the row data passed for validation
- getSanitizedData() : array<string|int, mixed>
- Returns sanitized (for strings) and validated data
- expandWildcardRules() : array<string|int, mixed>
- Expand rules containing wildcard (*)
- getFieldValue() : mixed
- Returns filed value
- parseLiteralValue() : mixed
- Parses a literal value and return is in the correct type (for null, boolean and numeric values)
- parseRuleString() : array<string|int, mixed>
- Returns array with the rules
- sanitizeString() : string|null
- Returns sanitized string
- setFiledValue() : void
- Sets field value
- validate() : array<string|int, mixed>
- Validates the data based on the defined rules.
- validateDate() : bool
- Validates if a value is a valid date, optionally against a specific format.
Properties
$data
private
array<string|int, mixed>
$data
= []
$errors
private
array<string|int, mixed>
$errors
= []
$rules
private
array<string|int, mixed>
$rules
= []
$sanitizedData
private
array<string|int, mixed>
$sanitizedData
= []
Methods
getErrors()
Returns the errors
public
getErrors() : array<string|int, mixed>
Return values
array<string|int, mixed>getRawData()
Returns the row data passed for validation
public
getRawData() : array<string|int, mixed>
Return values
array<string|int, mixed>getSanitizedData()
Returns sanitized (for strings) and validated data
public
getSanitizedData(array<string|int, mixed> $data, array<string|int, mixed> $rules) : array<string|int, mixed>
Parameters
- $data : array<string|int, mixed>
- $rules : array<string|int, mixed>
Return values
array<string|int, mixed>expandWildcardRules()
Expand rules containing wildcard (*)
private
expandWildcardRules() : array<string|int, mixed>
Return values
array<string|int, mixed>getFieldValue()
Returns filed value
private
getFieldValue(array<string|int, mixed> $array, string $key) : mixed
Parameters
- $array : array<string|int, mixed>
- $key : string
parseLiteralValue()
Parses a literal value and return is in the correct type (for null, boolean and numeric values)
private
parseLiteralValue(string $value) : mixed
Parameters
- $value : string
parseRuleString()
Returns array with the rules
private
parseRuleString(string $ruleString) : array<string|int, mixed>
Parameters
- $ruleString : string
Return values
array<string|int, mixed>sanitizeString()
Returns sanitized string
private
sanitizeString(type $value) : string|null
Parameters
- $value : type
Return values
string|nullsetFiledValue()
Sets field value
private
setFiledValue(array<string|int, mixed> &$array, string $key, type $value) : void
Parameters
- $array : array<string|int, mixed>
- $key : string
- $value : type
validate()
Validates the data based on the defined rules.
private
validate() : array<string|int, mixed>
Return values
array<string|int, mixed>validateDate()
Validates if a value is a valid date, optionally against a specific format.
private
validateDate(string $date[, string|null $format = null ]) : bool
Parameters
- $date : string
-
The date string to check.
- $format : string|null = null
-
The specific format to check against (e.g., 'Y-m-d').