Legend of the Green Dragon

ObjectExists extends AbstractValidator

Class that validates if objects exist in a given repository with a given list of matched fields.

Tags
license

MIT

see
http://www.doctrine-project.org/
author

Marco Pivetta ocramius@gmail.com

Table of Contents

ERROR_NO_OBJECT_FOUND  = 'noObjectFound'
Error constants.
$fields  : array<string|int, mixed>
Fields to be checked.
$messageTemplates  : array<string|int, mixed>
$objectRepository  : ObjectRepository
ObjectRepository from which to search for entities.
__construct()  : mixed
Constructor.
isValid()  : mixed
{@inheritdoc}
cleanSearchValue()  : array<string|int, mixed>
validateFields()  : array<string|int, mixed>
Filters and validates the fields passed to the constructor.

Constants

ERROR_NO_OBJECT_FOUND

Error constants.

public mixed ERROR_NO_OBJECT_FOUND = 'noObjectFound'

Properties

$fields

Fields to be checked.

protected array<string|int, mixed> $fields

$messageTemplates

protected array<string|int, mixed> $messageTemplates = [self::ERROR_NO_OBJECT_FOUND => "No object matching '%value%' was found"]

$objectRepository

ObjectRepository from which to search for entities.

protected ObjectRepository $objectRepository

Methods

__construct()

Constructor.

public __construct(array<string|int, mixed> $options) : mixed
Parameters
$options : array<string|int, mixed>

required keys are object_repository, which must be an instance of Doctrine\Common\Persistence\ObjectRepository, and fields, with either a string or an array of strings representing the fields to be matched by the validator

Tags
throws
InvalidArgumentException
Return values
mixed

isValid()

{@inheritdoc}

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

cleanSearchValue()

protected cleanSearchValue(string|array<string|int, mixed> $value) : array<string|int, mixed>
Parameters
$value : string|array<string|int, mixed>

a field value or an array of field values if more fields have been configured to be matched

Tags
throws
RuntimeException
Return values
array<string|int, mixed>

validateFields()

Filters and validates the fields passed to the constructor.

private validateFields() : array<string|int, mixed>
Tags
throws
InvalidArgumentException
Return values
array<string|int, mixed>

Search results