FormValidator
    
            
            in package
            
        
    
            
            implements
                            FormInterface,                             ArrayAccess,                             Countable,                             IteratorAggregate                    
    
            
            Uses
                            FormTrait                    
    
Form validator class
Tags
Table of Contents
Interfaces
- FormInterface
 - Form interface class
 - ArrayAccess
 - Countable
 - IteratorAggregate
 
Properties
- $errors : array<string|int, mixed>
 - Form validation errors
 - $required : array<string|int, mixed>
 - Required fields
 - $validators : array<string|int, mixed>
 - Form validators
 - $values : array<string|int, mixed>
 - Form values
 
Methods
- __construct() : mixed
 - Constructor
 - __get() : mixed
 - Get method to return the value of values[$name]
 - __isset() : bool
 - Return the isset value of values[$name]
 - __set() : void
 - Set method to set the property to the value of values[$name]
 - __unset() : void
 - Unset values[$name]
 - addValidator() : FormValidator
 - Add validator
 - addValidators() : FormValidator
 - Add validators
 - count() : int
 - Count of values
 - createFromConfig() : FormValidator
 - Create form validator from config
 - filter() : mixed
 - Filter values with the filters
 - filterValue() : mixed
 - Filter value with the filters
 - getError() : mixed
 - Get error
 - getErrors() : array<string|int, mixed>
 - Get errors
 - getIterator() : ArrayIterator
 - Method to iterate over the form elements
 - getValidator() : mixed
 - Get validator
 - getValidators() : mixed
 - Get validators
 - getValues() : array<string|int, mixed>
 - Get values
 - hasErrors() : bool
 - Has errors
 - hasValidator() : bool
 - Has validator
 - hasValidators() : bool
 - Has validators
 - isRequired() : bool
 - Is required
 - offsetExists() : bool
 - ArrayAccess offsetExists
 - offsetGet() : mixed
 - ArrayAccess offsetGet
 - offsetSet() : void
 - ArrayAccess offsetSet
 - offsetUnset() : void
 - ArrayAccess offsetUnset
 - removeRequired() : FormValidator
 - Remove required
 - removeValidator() : FormValidator
 - Remove validator
 - removeValidators() : FormValidator
 - Remove validators
 - setRequired() : FormValidator
 - Set required
 - setValues() : FormValidator
 - Set values
 - toArray() : array<string|int, mixed>
 - Get values
 - validate() : bool
 - Validate values
 - addError() : FormValidator
 - Add error
 
Properties
$errors
Form validation errors
    protected
        array<string|int, mixed>
    $errors
     = []
    
    
    
$required
Required fields
    protected
        array<string|int, mixed>
    $required
     = []
    
    
    
$validators
Form validators
    protected
        array<string|int, mixed>
    $validators
     = []
    
    
    
$values
Form values
    protected
        array<string|int, mixed>
    $values
     = []
    
    
    
Methods
__construct()
Constructor
    public
                    __construct([array<string|int, mixed>|null $validators = null ][, mixed $required = null ][, array<string|int, mixed>|null $values = null ][, mixed $filters = null ]) : mixed
    Instantiate the form validator object
Parameters
- $validators : array<string|int, mixed>|null = null
 - $required : mixed = null
 - $values : array<string|int, mixed>|null = null
 - $filters : mixed = null
 
__get()
Get method to return the value of values[$name]
    public
                    __get(string $name) : mixed
    Parameters
- $name : string
 
__isset()
Return the isset value of values[$name]
    public
                    __isset(string $name) : bool
    Parameters
- $name : string
 
Return values
bool__set()
Set method to set the property to the value of values[$name]
    public
                    __set(string $name, mixed $value) : void
    Parameters
- $name : string
 - $value : mixed
 
__unset()
Unset values[$name]
    public
                    __unset(string $name) : void
    Parameters
- $name : string
 
addValidator()
Add validator
    public
                    addValidator(string $field, mixed $validator) : FormValidator
    Parameters
- $field : string
 - $validator : mixed
 
Return values
FormValidatoraddValidators()
Add validators
    public
                    addValidators(array<string|int, mixed> $validators) : FormValidator
    Parameters
- $validators : array<string|int, mixed>
 
Return values
FormValidatorcount()
Count of values
    public
                    count() : int
    Return values
intcreateFromConfig()
Create form validator from config
    public
            static        createFromConfig(array<string|int, mixed>|FormConfig $formConfig[, mixed $required = null ][, array<string|int, mixed>|null $values = null ][, mixed $filters = null ]) : FormValidator
    Parameters
- $formConfig : array<string|int, mixed>|FormConfig
 - $required : mixed = null
 - $values : array<string|int, mixed>|null = null
 - $filters : mixed = null
 
Return values
FormValidatorfilter()
Filter values with the filters
    public
                    filter([mixed $values = null ]) : mixed
    Parameters
- $values : mixed = null
 
filterValue()
Filter value with the filters
    public
                    filterValue(mixed $field) : mixed
    Parameters
- $field : mixed
 
Tags
getError()
Get error
    public
                    getError(string $field, int $index) : mixed
    Parameters
- $field : string
 - $index : int
 
getErrors()
Get errors
    public
                    getErrors([string|null $field = null ]) : array<string|int, mixed>
    Parameters
- $field : string|null = null
 
Return values
array<string|int, mixed>getIterator()
Method to iterate over the form elements
    public
                    getIterator() : ArrayIterator
    Return values
ArrayIteratorgetValidator()
Get validator
    public
                    getValidator(string $field, int $index) : mixed
    Parameters
- $field : string
 - $index : int
 
getValidators()
Get validators
    public
                    getValidators([string $field = null ]) : mixed
    Parameters
- $field : string = null
 
getValues()
Get values
    public
                    getValues() : array<string|int, mixed>
    Return values
array<string|int, mixed>hasErrors()
Has errors
    public
                    hasErrors([string|null $field = null ]) : bool
    Parameters
- $field : string|null = null
 
Return values
boolhasValidator()
Has validator
    public
                    hasValidator(string $field, int $index) : bool
    Parameters
- $field : string
 - $index : int
 
Return values
boolhasValidators()
Has validators
    public
                    hasValidators([string|null $field = null ]) : bool
    Parameters
- $field : string|null = null
 
Return values
boolisRequired()
Is required
    public
                    isRequired(string $field) : bool
    Parameters
- $field : string
 
Return values
booloffsetExists()
ArrayAccess offsetExists
    public
                    offsetExists(mixed $offset) : bool
    Parameters
- $offset : mixed
 
Return values
booloffsetGet()
ArrayAccess offsetGet
    public
                    offsetGet(mixed $offset) : mixed
    Parameters
- $offset : mixed
 
offsetSet()
ArrayAccess offsetSet
    public
                    offsetSet(mixed $offset, mixed $value) : void
    Parameters
- $offset : mixed
 - $value : mixed
 
offsetUnset()
ArrayAccess offsetUnset
    public
                    offsetUnset(mixed $offset) : void
    Parameters
- $offset : mixed
 
removeRequired()
Remove required
    public
                    removeRequired(string $field) : FormValidator
    Parameters
- $field : string
 
Return values
FormValidatorremoveValidator()
Remove validator
    public
                    removeValidator(string $field, int $index) : FormValidator
    Parameters
- $field : string
 - $index : int
 
Return values
FormValidatorremoveValidators()
Remove validators
    public
                    removeValidators([string|null $field = null ]) : FormValidator
    Parameters
- $field : string|null = null
 
Return values
FormValidatorsetRequired()
Set required
    public
                    setRequired(mixed $required[, string|null $requiredMessage = 'This field is required.' ]) : FormValidator
    Parameters
- $required : mixed
 - $requiredMessage : string|null = 'This field is required.'
 
Return values
FormValidatorsetValues()
Set values
    public
                    setValues(array<string|int, mixed> $values) : FormValidator
    Parameters
- $values : array<string|int, mixed>
 
Return values
FormValidatortoArray()
Get values
    public
                    toArray([array<string|int, mixed> $options = [] ]) : array<string|int, mixed>
    Parameters
- $options : array<string|int, mixed> = []
 
Return values
array<string|int, mixed>validate()
Validate values
    public
                    validate([mixed $fields = null ]) : bool
    Parameters
- $fields : mixed = null
 
Return values
booladdError()
Add error
    protected
                    addError(string $field, string $error) : FormValidator
    Parameters
- $field : string
 - $error : string