Maslosoft Mangan API
Class NumericalValidatorAnnotation
Validator validates that the attribute value is a number.
In addition to the Maslosoft\Mangan\Annotations\Validators\ValidatorAnnotation::$message property for setting a custom error message,
NumberValidator has a couple custom error messages you can set that correspond to different
validation scenarios. To specify a custom message when the numeric value is too big,
you may use the Maslosoft\Mangan\Annotations\Validators\NumericalValidatorAnnotation::$tooBig property. Similarly with Maslosoft\Mangan\Annotations\Validators\NumericalValidatorAnnotation::$tooSmall.
The messages may contain additional placeholders that will be replaced
with the actual content. In addition to the "{attribute}" placeholder, recognized by all
validators (see Validator), NumberValidator allows for the following placeholders
to be specified:
- {min}: when using
Maslosoft\Mangan\Annotations\Validators\NumericalValidatorAnnotation::$tooSmall, replaced with the lower limit of the numberMaslosoft\Mangan\Annotations\Validators\NumericalValidatorAnnotation::$min. - {max}: when using
Maslosoft\Mangan\Annotations\Validators\NumericalValidatorAnnotation::$tooBig, replaced with the upper limit of the numberMaslosoft\Mangan\Annotations\Validators\NumericalValidatorAnnotation::$max.
- Maslosoft\Addendum\Collections\MetaAnnotation
-
Maslosoft\Mangan\Meta\ManganAnnotation
-
Maslosoft\Mangan\Meta\ManganPropertyAnnotation
-
Maslosoft\Mangan\Annotations\Validators\ValidatorAnnotation
-
Maslosoft\Mangan\Annotations\Validators\NumericalValidatorAnnotation
uses
Maslosoft\Mangan\Validators\Traits\AllowEmpty
Package: system\validators
Author: Qiang Xue qiang.xue@gmail.com
Version: $Id$
Since: 1.0
Located at Annotations/Validators/NumericalValidatorAnnotation.php
Methods inherited from Maslosoft\Mangan\Meta\ManganPropertyAnnotation
Methods inherited from Maslosoft\Mangan\Meta\ManganAnnotation
Constants summary
Constants inherited from Maslosoft\Mangan\Annotations\Validators\ValidatorAnnotation
Properties summary
public
boolean
|
$integerOnly
whether the attribute value can only be an integer. Defaults to false. |
#
false
|
public
integer|float
|
$max
upper limit of the number. Defaults to null, meaning no upper limit. |
#
NULL
|
public
integer|float
|
$min
lower limit of the number. Defaults to null, meaning no lower limit. |
#
NULL
|
public
string
|
$tooBig
user-defined error message used when the value is too big. |
#
NULL
|
public
string
|
$tooSmall
user-defined error message used when the value is too small. |
#
NULL
|
Properties inherited from Maslosoft\Mangan\Annotations\Validators\ValidatorAnnotation
$class,
$except,
$message,
$on,
$proxy,
$safe,
$skipOnError,
$value