class IP extends Rule implements RuleInterface

IP rule.

Traits

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

Properties

protected I18n $i18n I18n. from I18nAwareTrait
protected string|null $version IP version.
protected array $i18nParameters I18n parameters.

Methods

bool
validateWhenEmpty()

Returns TRUE if the rule should be executed when the input is empty and FALSE if not.

setI18n(I18n $i18n)

Sets the I18n instance.

string
translateFieldName(string $field, string $package)

Returns a translated field name.

array
getI18nParameters(string $field, string $package)

Gets the i18n parameters.

string
getErrorMessage(string $field)

Returns an error message.

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

Returns the translated error message.

__construct(string|null $version = null)

Constructor.

int|null
getFlags()

Returns the filter flags.

string
getVersion()

Returns the name of the IP version that we're validating.

bool
validate(mixed $value, array $input)

Returns TRUE if the rule succeeds and FALSE if not.

Details

bool validateWhenEmpty()

Returns TRUE if the rule should be executed when the input is empty and FALSE if not.

Return Value

bool

in I18nAwareTrait at line 42
I18nAwareInterface setI18n(I18n $i18n)

Sets the I18n instance.

Parameters

I18n $i18n I18n

Return Value

I18nAwareInterface

in I18nAwareTrait at line 56
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 77
protected array getI18nParameters(string $field, string $package)

Gets the i18n parameters.

Parameters

string $field Field name
string $package Package prefix

Return Value

array

at line 97
string getErrorMessage(string $field)

Returns an error message.

Parameters

string $field Field name

Return Value

string

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

Returns the translated error message.

Parameters

string $field Field name
string $rule Rule name
string|null $package Package name

Return Value

string

at line 33
__construct(string|null $version = null)

Constructor.

Parameters

string|null $version IP version

at line 50
protected int|null getFlags()

Returns the filter flags.

Return Value

int|null

at line 73
protected string getVersion()

Returns the name of the IP version that we're validating.

Return Value

string

at line 89
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