Neuron-PHP

Collection extends Base
in package
implements ICollection

Allows multiple validators to be chained in one item.

Table of Contents

Interfaces

ICollection
Validation collection.

Properties

$_failed  : array<string|int, mixed>
$_validators  : array<string|int, mixed>

Methods

__construct()  : mixed
add()  : $this
Adds a named validator to the collection.
get()  : IValidator|null
Gets a validator by name.
getViolations()  : mixed
Returns the list of failed validations.
isValid()  : bool
Returns true if validation is successful
remove()  : bool
Removes a validator by name.
validateItem()  : void
Validate an individual item by name.
validate()  : bool
Abstract method to be implemented by all validators.

Properties

$_failed

private array<string|int, mixed> $_failed = []

$_validators

private array<string|int, mixed> $_validators = []

Methods

add()

Adds a named validator to the collection.

public add(string $name, IValidator $validator) : $this
Parameters
$name : string
$validator : IValidator
Return values
$this

Add a validator to the collection.

getViolations()

Returns the list of failed validations.

public getViolations() : mixed

isValid()

Returns true if validation is successful

public isValid(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

remove()

Removes a validator by name.

public remove(string $name) : bool
Parameters
$name : string
Return values
bool

validateItem()

Validate an individual item by name.

public validateItem(IValidator $validator, string $name, mixed $data) : void
Parameters
$validator : IValidator
$name : string
$data : mixed

validate()

Abstract method to be implemented by all validators.

protected validate(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

        
On this page

Search results