class Exists extends Rule implements RuleInterface, WithParametersInterface

Exists rule.

Traits

With parameters trait.
I18n aware trait.
Doesn't validate when empty trait.

Properties

protected I18n $i18n I18n. from I18nAwareTrait
protected array $parameters Parameters.
protected ConnectionManager $database Connection manager.

Methods

setI18n(I18n $i18n)

{@inheritdoc}

string
translateFieldName(string $field, string $package)

Returns a translated field name.

array
getI18nParameters(string $field, string $package)

Gets the i18n parameters.

getTranslatedErrorMessage(string $field, string $rule, string $package = null)

{@inheritdoc}

setParameters(array $parameters)

{@inheritdoc}

mixed
getParameter(string $name, bool $optional = false)

Returns the parameter value.

__construct(ConnectionManager $database)

Constructor.

bool
validate(mixed $value, array $input)

Returns true if the rule succeeds and false if not.

string
getErrorMessage(string $field)

Returns an error message.

Details

in I18nAwareTrait at line 39
setI18n(I18n $i18n)

{@inheritdoc}

Parameters

I18n $i18n

in I18nAwareTrait at line 53
protected string translateFieldName(string $field, string $package)

Returns a translated field name.

Parameters

string $field Field name
string $package Package prefix

Return Value

string

in I18nAwareTrait at line 74
protected array getI18nParameters(string $field, string $package)

Gets the i18n parameters.

Parameters

string $field Field name
string $package Package prefix

Return Value

array

in I18nAwareTrait at line 100
getTranslatedErrorMessage(string $field, string $rule, string $package = null)

{@inheritdoc}

Parameters

string $field
string $rule
string $package

validateWhenEmpty()

{@inheritdoc}

in WithParametersTrait at line 27
setParameters(array $parameters)

{@inheritdoc}

Parameters

array $parameters

in WithParametersTrait at line 39
protected mixed getParameter(string $name, bool $optional = false)

Returns the parameter value.

Parameters

string $name Parameter name
bool $optional Is the parameter optional?

Return Value

mixed

at line 46
__construct(ConnectionManager $database)

Constructor.

Parameters

ConnectionManager $database Connection manager

at line 54
bool validate(mixed $value, array $input)

Returns true if the rule succeeds and false if not.

Parameters

mixed $value Value to validate
array $input Input

Return Value

bool

at line 67
string getErrorMessage(string $field)

Returns an error message.

Parameters

string $field Field name

Return Value

string