StringLengthValidator checks a string's length.
More...
|
| truncateValue ( $value, $truncateAt=32) |
| Truncates the value to the max length, if the value is larger than some maximum length.
|
|
StringLengthValidator checks a string's length.
- Copyright
- GPL-2.0-or-later
- Author
- Daniel Kinzler
◆ __construct()
Wikibase\Repo\Validators\StringLengthValidator::__construct |
( |
| $minLength, |
|
|
| $maxLength, |
|
|
| $measure = 'strlen', |
|
|
| $errorCodePrefix = '' ) |
- Parameters
-
int | $minLength | |
int | $maxLength | |
callable | string | $measure | The function to use to measure the string's length. Use 'strlen' for byte length and 'mb_strlen' for character length. A callable can be used to provide an alternative measure. |
string | $errorCodePrefix | |
◆ setOptions()
Wikibase\Repo\Validators\StringLengthValidator::setOptions |
( |
array | $options | ) |
|
- See also
- ValueValidator::setOptions()
- Parameters
-
◆ truncateValue()
Wikibase\Repo\Validators\StringLengthValidator::truncateValue |
( |
| $value, |
|
|
| $truncateAt = 32 ) |
|
private |
Truncates the value to the max length, if the value is larger than some maximum length.
To be used only for informative purposes (such as error messages) when the value is already known to be longer than the maximum specified in the constructor.
- Parameters
-
string | $value | |
int | $truncateAt | The length after which to truncate. Note that this is unrelated to the max length we validate against. |
- Returns
- string
◆ validate()
Wikibase\Repo\Validators\StringLengthValidator::validate |
( |
| $value | ) |
|
- See also
- ValueValidator::validate()
- Parameters
-
string | $value | The value to validate |
- Returns
- Result
◆ $errorCodePrefix
Wikibase\Repo\Validators\StringLengthValidator::$errorCodePrefix |
|
private |
◆ $maxLength
Wikibase\Repo\Validators\StringLengthValidator::$maxLength |
|
private |
◆ $measure
Wikibase\Repo\Validators\StringLengthValidator::$measure |
|
private |
◆ $minLength
Wikibase\Repo\Validators\StringLengthValidator::$minLength |
|
private |
The documentation for this class was generated from the following file: