Documentation

FormValidator
in package
implements FormInterface, ArrayAccess, Countable, IteratorAggregate Uses FormTrait

Form validator class

Tags
category

Pop

author

Nick Sagona, III dev@nolainteractive.com

copyright

Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com)

license

http://www.popphp.org/license New BSD License

version
4.0.0

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

count()

Count of values

public count() : int
Return values
int

createFromConfig()

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
FormValidator

filter()

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
throws
Exception

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
ArrayIterator

getValidator()

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
bool

hasValidator()

Has validator

public hasValidator(string $field, int $index) : bool
Parameters
$field : string
$index : int
Return values
bool

hasValidators()

Has validators

public hasValidators([string|null $field = null ]) : bool
Parameters
$field : string|null = null
Return values
bool

isRequired()

Is required

public isRequired(string $field) : bool
Parameters
$field : string
Return values
bool

offsetExists()

ArrayAccess offsetExists

public offsetExists(mixed $offset) : bool
Parameters
$offset : mixed
Return values
bool

offsetGet()

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

setRequired()

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
FormValidator

toArray()

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
bool

        
On this page

Search results