Maslosoft Mangan API
Class CompareValidatorAnnotation
CompareValidator compares the specified attribute value with another value and validates if they are equal.
The value being compared with can be another attribute value
(specified via Maslosoft\Mangan\Annotations\Validators\CompareValidatorAnnotation::$compareAttribute
) or a constant (specified via
Maslosoft\Mangan\Annotations\Validators\CompareValidatorAnnotation::$compareValue
. When both are specified, the latter takes
precedence. If neither is specified, the attribute will be compared
with another attribute whose name is by appending "_repeat" to the source
attribute name.
The comparison can be either Maslosoft\Mangan\Annotations\Validators\CompareValidatorAnnotation::$strict
or not.
CompareValidator supports different comparison operators. Previously, it only compares to see if two values are equal or not.
When using the Maslosoft\Mangan\Annotations\Validators\ValidatorAnnotation::$message
property to define a custom error message, the message
may contain additional placeholders that will be replaced with the actual content. In addition
to the "{attribute}" placeholder, recognized by all validators (see Validator),
CompareValidator allows for the following placeholders to be specified:
- {compareValue}: replaced with the constant value being compared with
Maslosoft\Mangan\Annotations\Validators\CompareValidatorAnnotation::$compareValue
.
- Maslosoft\Addendum\Collections\MetaAnnotation
- Maslosoft\Mangan\Meta\ManganAnnotation
- Maslosoft\Mangan\Meta\ManganPropertyAnnotation
- Maslosoft\Mangan\Annotations\Validators\ValidatorAnnotation
- Maslosoft\Mangan\Annotations\Validators\CompareValidatorAnnotation uses Maslosoft\Mangan\Validators\Traits\AllowEmpty, Maslosoft\Mangan\Validators\Traits\Strict
Package: system\validators
Author: Qiang Xue qiang.xue@gmail.com
Version: $Id$
Since: 1.0
Located at Annotations/Validators/CompareValidatorAnnotation.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
string
|
$compareAttribute
the name of the attribute to be compared with |
#
NULL
|
public
string
|
$compareValue
the constant value to be compared with |
#
NULL
|
public
string
|
$operator
the operator for comparison. Defaults to '='. The followings are valid operators:
|
#
'='
|
Properties inherited from Maslosoft\Mangan\Annotations\Validators\ValidatorAnnotation
$class
,
$except
,
$message
,
$on
,
$proxy
,
$safe
,
$skipOnError
,
$value