Validator
class Validator
Input validation.
Traits
Properties
protected array | $input | Input. | |
protected array | $ruleSets | Rule sets. | |
protected I18n | $i18n | I18n. | |
protected Container | $container | Container. | |
protected array | $rules | Rules. | |
protected array | $originalFieldNames | Original field names. | |
protected bool | $isValid | Is the input valid? | |
protected array | $errors | Error messages. |
Methods
Splits function name and parameters into an array.
Parses custom "function calls".
Constructor.
Rule builder.
Returns TRUE if the field name has a wildcard and FALSE if not.
Saves original field name along with the expanded field name.
Returns the original field name.
Expands fields.
Adds validation rules to input field if the condition is met.
Parses the rule.
Returns the rule class name.
Creates a rule instance.
Returns TRUE if the input field is considered empty and FALSE if not.
Validates the field using the specified rule.
Processes all validation rules and returns an array containing the validation status and potential error messages.
Returns TRUE if all rules passed and FALSE if validation failed.
Returns false if all rules passed and true if validation failed.
Validates the input and returns an array containing validated data.
Returns the validation errors.
Details
in FunctionParserTrait at line 31
protected array
splitFunctionAndParameters(string $function)
Splits function name and parameters into an array.
in FunctionParserTrait at line 50
protected array
parseFunction(string $function, bool|null $namedParameters = null)
Parses custom "function calls".
The return value is an array consisting of the function name and parameters.
at line 208
__construct(array $input, array $ruleSets = [], I18n|null $i18n = null, Container|null $container = null)
Constructor.
at line 226
static string
rule(string $ruleName, mixed ...$parameters)
Rule builder.
at line 243
Validator
extend(string $rule, string $ruleClass)
Registers a custom validation rule.
at line 256
protected bool
hasWilcard(string $string)
Returns TRUE if the field name has a wildcard and FALSE if not.
at line 267
protected
saveOriginalFieldNames(array $fields, string $field)
Saves original field name along with the expanded field name.
at line 281
protected string
getOriginalFieldName(string $field)
Returns the original field name.
at line 292
protected array
expandFields(array $ruleSets)
Expands fields.
at line 328
Validator
addRules(string $field, array $ruleSet)
Adds validation rules to input field.
at line 343
Validator
addRulesIf(string $field, array $ruleSet, bool|Closure $condition)
Adds validation rules to input field if the condition is met.
at line 359
protected object
parseRule(string $rule)
Parses the rule.
at line 379
protected string
getRuleClassName(string $name)
Returns the rule class name.
at line 396
protected RuleInterface
ruleFactory(string $name, array $parameters)
Creates a rule instance.
at line 407
protected bool
isInputFieldEmpty(mixed $value)
Returns TRUE if the input field is considered empty and FALSE if not.
at line 420
protected string
getErrorMessage(RuleInterface $rule, string $field, object $parsedRule)
Returns the error message.
at line 439
protected bool
validateField(string $field, string $rule)
Validates the field using the specified rule.
at line 470
protected array
process()
Processes all validation rules and returns an array containing the validation status and potential error messages.
at line 498
bool
isValid(array $errors = null)
Returns TRUE if all rules passed and FALSE if validation failed.
at line 511
bool
isInvalid(array $errors = null)
Returns false if all rules passed and true if validation failed.
at line 523
array
validate()
Validates the input and returns an array containing validated data.
at line 548
array
getErrors()
Returns the validation errors.