Documentation

Collection extends Composite
in package

A constraint that is composed of other constraints.

Tags
Annotation
Target

({"PROPERTY", "METHOD", "ANNOTATION"})

author

Bernhard Schussek bschussek@gmail.com

Table of Contents

Constants

CLASS_CONSTRAINT  = 'class'
Marks a constraint that can be put onto classes.
DEFAULT_GROUP  = 'Default'
The name of the group given to all constraints with no explicit group.
MISSING_FIELD_ERROR  = '2fa2158c-2a7f-484b-98aa-975522539ff8'
NO_SUCH_FIELD_ERROR  = '7703c766-b5d5-4cef-ace7-ae0dd82304e9'
PROPERTY_CONSTRAINT  = 'property'
Marks a constraint that can be put onto properties.

Properties

$allowExtraFields  : mixed
$allowMissingFields  : mixed
$extraFieldsMessage  : mixed
$fields  : mixed
$groups  : array<string|int, string>
The groups that the constraint belongs to.
$missingFieldsMessage  : mixed
$payload  : mixed
Domain-specific data attached to a constraint.
$errorNames  : mixed

Methods

__construct()  : mixed
Initializes the constraint with options.
__get()  : mixed
Returns the value of a lazily initialized option.
__isset()  : bool
__set()  : mixed
Sets the value of a lazily initialized option.
addImplicitGroupName()  : mixed
Adds the given group if this constraint is in the Default group.
getDefaultOption()  : string|null
Returns the name of the default option.
getErrorName()  : string
Returns the name of the given error code.
getRequiredOptions()  : array<string|int, mixed>
getTargets()  : string|array<string|int, string>
Returns whether the constraint can be put onto classes, properties or both.
validatedBy()  : string
Returns the name of the class that validates this constraint.
getCompositeOption()  : string
Returns the name of the property that contains the nested constraints.
initializeNestedConstraints()  : mixed
Initializes the nested constraints.
normalizeOptions()  : array<string|int, mixed>

Constants

CLASS_CONSTRAINT

Marks a constraint that can be put onto classes.

public mixed CLASS_CONSTRAINT = 'class'

DEFAULT_GROUP

The name of the group given to all constraints with no explicit group.

public mixed DEFAULT_GROUP = 'Default'

MISSING_FIELD_ERROR

public mixed MISSING_FIELD_ERROR = '2fa2158c-2a7f-484b-98aa-975522539ff8'

NO_SUCH_FIELD_ERROR

public mixed NO_SUCH_FIELD_ERROR = '7703c766-b5d5-4cef-ace7-ae0dd82304e9'

PROPERTY_CONSTRAINT

Marks a constraint that can be put onto properties.

public mixed PROPERTY_CONSTRAINT = 'property'

Properties

$allowExtraFields

public mixed $allowExtraFields = false

$allowMissingFields

public mixed $allowMissingFields = false

$extraFieldsMessage

public mixed $extraFieldsMessage = 'This field was not expected.'

$groups

The groups that the constraint belongs to.

public array<string|int, string> $groups

$missingFieldsMessage

public mixed $missingFieldsMessage = 'This field is missing.'

$payload

Domain-specific data attached to a constraint.

public mixed $payload

$errorNames

protected static mixed $errorNames = [self::MISSING_FIELD_ERROR => 'MISSING_FIELD_ERROR', self::NO_SUCH_FIELD_ERROR => 'NO_SUCH_FIELD_ERROR']

Methods

__construct()

Initializes the constraint with options.

public __construct([mixed $fields = null ][, array<string|int, mixed> $groups = null ][, mixed $payload = null ][, bool $allowExtraFields = null ][, bool $allowMissingFields = null ][, string $extraFieldsMessage = null ][, string $missingFieldsMessage = null ]) : mixed
Parameters
$fields : mixed = null
$groups : array<string|int, mixed> = null

An array of validation groups

$payload : mixed = null

Domain-specific data attached to a constraint

$allowExtraFields : bool = null
$allowMissingFields : bool = null
$extraFieldsMessage : string = null
$missingFieldsMessage : string = null

__get()

Returns the value of a lazily initialized option.

public __get(string $option) : mixed

Corresponding properties are added to the object on first access. Hence this method will be called at most once per constraint instance and option name.

Parameters
$option : string
Tags
throws
InvalidOptionsException

If an invalid option name is given

__isset()

public __isset(string $option) : bool
Parameters
$option : string
Return values
bool

__set()

Sets the value of a lazily initialized option.

public __set(string $option, mixed $value) : mixed

Corresponding properties are added to the object on first access. Hence this method will be called at most once per constraint instance and option name.

Parameters
$option : string
$value : mixed
Tags
throws
InvalidOptionsException

If an invalid option name is given

addImplicitGroupName()

Adds the given group if this constraint is in the Default group.

public addImplicitGroupName(string $group) : mixed
Parameters
$group : string

getDefaultOption()

Returns the name of the default option.

public getDefaultOption() : string|null

Override this method to define a default option.

Tags
see
__construct()
Return values
string|null

getErrorName()

Returns the name of the given error code.

public static getErrorName(string $errorCode) : string
Parameters
$errorCode : string
Tags
throws
InvalidArgumentException

If the error code does not exist

Return values
string

getRequiredOptions()

public getRequiredOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>

getTargets()

Returns whether the constraint can be put onto classes, properties or both.

public getTargets() : string|array<string|int, string>

This method should return one or more of the constants Constraint::CLASS_CONSTRAINT and Constraint::PROPERTY_CONSTRAINT.

Return values
string|array<string|int, string>

One or more constant values

validatedBy()

Returns the name of the class that validates this constraint.

public validatedBy() : string

By default, this is the fully qualified name of the constraint class suffixed with "Validator". You can override this method to change that behavior.

Return values
string

getCompositeOption()

Returns the name of the property that contains the nested constraints.

protected getCompositeOption() : string
Return values
string

initializeNestedConstraints()

Initializes the nested constraints.

protected initializeNestedConstraints() : mixed

normalizeOptions()

protected normalizeOptions(mixed $options) : array<string|int, mixed>
Parameters
$options : mixed
Return values
array<string|int, mixed>

        
On this page

Search results