Maslosoft Mangan API
Class CountValidatorAnnotation
CountValidator validates that the attribute array elements count is of certain length.
Note, this validator should only be used with array type attributes or
Countable
interface instance object.
In addition to the Maslosoft\Mangan\Annotations\Validators\ValidatorAnnotation::$message
property for setting a custom error message,
CountValidator has a couple custom error messages you can set that correspond to different
validation scenarios. For defining a custom message when the string is too short,
you may use the Maslosoft\Mangan\Annotations\Validators\CountValidatorAnnotation::$tooShort
property. Similarly with Maslosoft\Mangan\Annotations\Validators\CountValidatorAnnotation::$tooLong
. The messages may contain
placeholders that will be replaced with the actual content. In addition to the "{attribute}"
placeholder, recognized by all validators (see Validator), StringValidator allows for the following
placeholders to be specified:
- {min}: when using
Maslosoft\Mangan\Annotations\Validators\CountValidatorAnnotation::$tooShort
, replaced with minimum length,Maslosoft\Mangan\Annotations\Validators\CountValidatorAnnotation::$min
, if set. - {max}: when using
Maslosoft\Mangan\Annotations\Validators\CountValidatorAnnotation::$tooLong
, replaced with the maximum length,Maslosoft\Mangan\Annotations\Validators\CountValidatorAnnotation::$max
, if set. - {length}: when using
Maslosoft\Mangan\Annotations\Validators\ValidatorAnnotation::$message
, replaced with the exact required length,Maslosoft\Mangan\Annotations\Validators\CountValidatorAnnotation::$is
, if set.
- Maslosoft\Addendum\Collections\MetaAnnotation
- Maslosoft\Mangan\Meta\ManganAnnotation
- Maslosoft\Mangan\Meta\ManganPropertyAnnotation
- Maslosoft\Mangan\Annotations\Validators\ValidatorAnnotation
- Maslosoft\Mangan\Annotations\Validators\CountValidatorAnnotation uses Maslosoft\Mangan\Validators\Traits\AllowEmpty, Maslosoft\Mangan\Validators\Traits\When
Package: system\validators
Author: Qiang Xue qiang.xue@gmail.com
Version: $Id$
Since: 1.0
Located at Annotations/Validators/CountValidatorAnnotation.php
Methods inherited from Maslosoft\Mangan\Meta\ManganPropertyAnnotation
Methods inherited from Maslosoft\Mangan\Meta\ManganAnnotation
Methods used from Maslosoft\Mangan\Validators\Traits\When
Constants summary
Constants inherited from Maslosoft\Mangan\Annotations\Validators\ValidatorAnnotation
Properties summary
public
integer
|
$max
maximum length. Defaults to null, meaning no maximum limit. |
#
null
|
public
integer
|
$min
minimum length. Defaults to null, meaning no minimum limit. |
#
null
|
public
integer
|
$is
exact length. Defaults to null, meaning no exact length limit. |
#
null
|
public
string
|
$tooShort
user-defined error message used when the value is too short. |
#
null
|
public
string
|
$tooLong
user-defined error message used when the value is too long. |
#
null
|
public
string
|
$msgInvalid
|
#
''
|
public
string
|
$msgTooShort
|
#
''
|
public
string
|
$msgTooLong
|
#
''
|
public
string
|
$msgLength
|
#
''
|
Properties inherited from Maslosoft\Mangan\Annotations\Validators\ValidatorAnnotation
$class
,
$except
,
$message
,
$on
,
$proxy
,
$safe
,
$skipOnError
,
$value