interface ValidatorForSubjectInterface implements ValidatorInterface (View source)

A generic validator cabable of describing itself and validating mixed values, with the possibility to specify the subject for whom a value is valid.

Methods

string[]
getRequirementStrings()

Get the validator requirements in the form of an array keyed by it's respective error code.

bool
isValid(mixed $mixed, ArrayAccess $error = null)

Is this mixed value valid.

bool
isValidFor(mixed $mixed, mixed $subject = null, ArrayAccess $error = null)

Is this mixed value valid for the specified (optional) subject?

Details

string[] getRequirementStrings()

Get the validator requirements in the form of an array keyed by it's respective error code.

Return Value

string[]

bool isValid(mixed $mixed, ArrayAccess $error = null)

Is this mixed value valid.

Parameters

mixed $mixed Can be any value
ArrayAccess $error

Return Value

bool

Exceptions

InvalidArgumentException invalid mixed value type passed

bool isValidFor(mixed $mixed, mixed $subject = null, ArrayAccess $error = null)

Is this mixed value valid for the specified (optional) subject?

Parameters

mixed $mixed Can be any value
mixed $subject The subject the value should be valid for
ArrayAccess $error

Return Value

bool

Exceptions

InvalidArgumentException throws a InvalidArgumentException when $mixed or $subject are not valid