Maslosoft Mangan Documentation
MongoDB Object Persister
Number
Number validator allows to check numeric value if it is over maximum or below minimum threshold. Can also check if number is integer.
Usage
To use number validator, use @NumericalValidator
annotation on numeric property,
with options:
/**
* @NumericalValidator('min' = 64, 'max' = 1024)
*/
public $maxSize = 128;
Besides this validator specific properties (all are optional):
$min
- minimum required value$max
- maximum allowed value$integerOnly
- whether require integer number
It has far more, common properties:
Property | Documentation |
---|---|
$allowEmpty |
meaning that if the attribute is empty, it is considered valid. |
$except |
Scenario on which validator should not be used. If empty, validator will be used on every scenario. |
$gt |
Number must be greater than. Defaults to null, meaning no constraint. |
$integerOnly |
Whether the attribute value can only be an integer. Defaults to false. |
$lt |
Number must be lesser than. Defaults to null, meaning no constraint. |
$max |
Upper limit of the number. Defaults to null, meaning no upper limit. |
$message |
Custom error message. May contain special placeholders, ie: {attribute}, {value} which will be replaced with attribute label or value, depending on validator. NOTE: This message will be used instead of any other validtor messages when set. |
$min |
Lower limit of the number. Defaults to null, meaning no lower limit. |
$msgGt |
Custom message to show if value must be greater than required |
$msgInteger |
Custom message to show if value is not integer when integer checking is enabled |
$msgLt |
Custom message to show if value is lesser than required |
$msgNumber |
Custom message to show if value is not number |
$msgTooBig |
Custom message to show if value is under minimum |
$msgTooSmall |
Custom message to show if value is over maximum |
$on |
Scenario on which validator should be used. If empty, validator will be used on every scenario. |
$safe |
When this is true atrtibute is considered safe, as it is validated |
$skipOnError |
Whether this validation rule should be skipped if when there is already a validation error for the current attribute. Defaults to true. |
$tooBig |
Deprecated: Use |
$tooSmall |
Deprecated: Use |