Piwik\Validators\

CharacterLength

Validator that fails when a string or number has fewer characters than the minimum or more than the maximum.

Values of other types, including null and false, are accepted.

Methods

The class defines the following methods:

validate()

Validates the given value and throws an exception if it is invalid.

Signature

  • It accepts the following parameter(s):
    • $value (mixed) — The value to validate.
  • It does not return anything or a mixed result.

check()

Lets you easily check a value against multiple validators.

Signature

  • It accepts the following parameter(s):
    • $name (string) — The name/description of the field you want to validate the value for. The name will be prefixed in case there is any error.
    • $value (mixed) — The value which needs to be tested
    • $validators (BaseValidator[]) — The validators to apply, in order.
  • It does not return anything or a mixed result.

__construct()

Signature

  • It accepts the following parameter(s):
    • $min (null|int) — The minimum number of characters, or null for no minimum.
    • $max (null|int) — The maximum number of characters, or null for no maximum.