class UniqueEntityValidator extends AbstractValidator (View source)

Validator for uniqueness of entities.

Properties

protected bool $acceptsEmptyValues

Specifies whether this validator accepts empty values.

from  AbstractValidator
protected array $supportedOptions
protected array $options from  AbstractValidator
protected Result[] $resultStack from  AbstractValidator
protected ReflectionService $reflectionService
protected PersistenceManagerInterface $persistenceManager

Methods

__construct(array $options = [])

Constructs the validator and sets validation options

pushResult()

Push a new Result onto the Result stack and return it in order to fix cyclic calls to a single validator.

popResult()

Pop and return the current Result from the stack and make $this->result point to the last Result again.

getResult()

Get the current Result for this validation invocation. Use this inside your isValid() implementation to e.g. merge results together into the current one.

validate(mixed $value)

Checks if the given value is valid according to the validator, and returns the Error Messages object which occurred.

void
isValid(mixed $value)

Checks if the given value is a unique entity depending on it's identity properties or custom configured identity properties.

void
addError(string $message, int $code, array $arguments = [])

Creates a new validation error object and adds it to $this->errors

array
getOptions()

Returns the options of this validator

bool
isEmpty(mixed $value)

No description

Details

__construct(array $options = [])

Constructs the validator and sets validation options

Parameters

array $options

Options for the validator

Exceptions

InvalidValidationOptionsException

protected pushResult()

Push a new Result onto the Result stack and return it in order to fix cyclic calls to a single validator.

protected popResult()

Pop and return the current Result from the stack and make $this->result point to the last Result again.

protected getResult()

Get the current Result for this validation invocation. Use this inside your isValid() implementation to e.g. merge results together into the current one.

Result validate(mixed $value)

Checks if the given value is valid according to the validator, and returns the Error Messages object which occurred.

Parameters

mixed $value

The value that should be validated

Return Value

Result

Exceptions

InvalidValidationOptionsException

protected void isValid(mixed $value)

Checks if the given value is a unique entity depending on it's identity properties or custom configured identity properties.

Parameters

mixed $value

Return Value

void

Exceptions

InvalidValidationOptionsException

protected void addError(string $message, int $code, array $arguments = [])

Creates a new validation error object and adds it to $this->errors

Parameters

string $message

The error message

int $code

The error code (a unix timestamp)

array $arguments

Arguments to be replaced in message

Return Value

void

array getOptions()

Returns the options of this validator

Return Value

array

final protected bool isEmpty(mixed $value)

No description

Parameters

mixed $value

Return Value

bool

true if the given $value is NULL or an empty string ('')