Class yii\mongodb\validators\MongoDateValidator
Inheritance | yii\mongodb\validators\MongoDateValidator » yii\validators\DateValidator » yii\validators\Validator » yii\base\Component » yii\base\BaseObject |
---|---|
Implements | yii\base\Configurable |
Available since version | 2.0.4 |
Source Code | https://github.com/yiisoft/yii2-mongodb/blob/master/validators/MongoDateValidator.php |
MongoDateValidator is an enhanced version of yii\validators\DateValidator, which supports \MongoDate values.
Usage example:
class Customer extends yii\mongodb\ActiveRecord
{
...
public function rules()
{
return [
['date', 'yii\mongodb\validators\MongoDateValidator', 'format' => 'MM/dd/yyyy']
];
}
}
See also yii\validators\DateValidator.
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$attributes | array|string | Attributes to be validated by this validator. | yii\validators\Validator |
$builtInValidators | array | List of built-in validators (name => class or configuration) | yii\validators\Validator |
$defaultTimeZone | string | The default timezone used for parsing when no time parts are provided in the format. | yii\validators\DateValidator |
$enableClientValidation | boolean | Whether to enable client-side validation for this validator. | yii\validators\Validator |
$except | array|string | Scenarios that the validator should not be applied to. | yii\validators\Validator |
$format | string | The date format that the value being validated should follow. | yii\validators\DateValidator |
$isEmpty | callable | A PHP callable that replaces the default implementation of isEmpty(). | yii\validators\Validator |
$locale | string | The locale ID that is used to localize the date parsing. | yii\validators\DateValidator |
$max | integer|string | Upper limit of the date. | yii\validators\DateValidator |
$maxString | string | User friendly value of upper limit to display in the error message. | yii\validators\DateValidator |
$message | string | The user-defined error message. | yii\validators\Validator |
$min | integer|string | Lower limit of the date. | yii\validators\DateValidator |
$minString | string | User friendly value of lower limit to display in the error message. | yii\validators\DateValidator |
$mongoDateAttribute | string | The name of the attribute to receive the parsing result as \MongoDate instance. | yii\mongodb\validators\MongoDateValidator |
$on | array|string | Scenarios that the validator can be applied to. | yii\validators\Validator |
$skipOnEmpty | boolean | Whether this validation rule should be skipped if the attribute value is null or an empty string. | yii\validators\Validator |
$skipOnError | boolean | Whether this validation rule should be skipped if the attribute being validated already has some validation error according to some previous rules. | yii\validators\Validator |
$strictDateFormat | boolean | Set this parameter to true if you need strict date format validation (e.g. only such dates pass validation for the following format 'yyyy-MM-dd': '0011-03-25', '2019-04-30' etc. | yii\validators\DateValidator |
$timeZone | string | The timezone to use for parsing date and time values. | yii\validators\DateValidator |
$timestampAttribute | string | The name of the attribute to receive the parsing result. | yii\validators\DateValidator |
$timestampAttributeFormat | string | The format to use when populating the $timestampAttribute. | yii\validators\DateValidator |
$timestampAttributeTimeZone | string | The timezone to use when populating the $timestampAttribute with $timestampAttributeFormat. | yii\validators\DateValidator |
$tooBig | string | User-defined error message used when the value is bigger than $max. | yii\validators\DateValidator |
$tooSmall | string | User-defined error message used when the value is smaller than $min. | yii\validators\DateValidator |
$type | string | The type of the validator. | yii\validators\DateValidator |
$when | callable | A PHP callable whose return value determines whether this validator should be applied. | yii\validators\Validator |
$whenClient | string | A JavaScript function name whose return value determines whether this validator should be applied on the client-side. | yii\validators\Validator |
Public Methods
Method | Description | Defined By |
---|---|---|
__call() | Calls the named method which is not a class method. | yii\base\Component |
__clone() | This method is called after the object is created by cloning an existing one. | yii\base\Component |
__construct() | Constructor. | yii\base\BaseObject |
__get() | Returns the value of a component property. | yii\base\Component |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\base\Component |
__set() | Sets the value of a component property. | yii\base\Component |
__unset() | Sets a component property to be null. | yii\base\Component |
addError() | Adds an error about the specified attribute to the model object. | yii\validators\Validator |
attachBehavior() | Attaches a behavior to this component. | yii\base\Component |
attachBehaviors() | Attaches a list of behaviors to the component. | yii\base\Component |
behaviors() | Returns a list of behaviors that this component should behave as. | yii\base\Component |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\base\Component |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\base\Component |
className() | Returns the fully qualified name of this class. | yii\base\BaseObject |
clientValidateAttribute() | Returns the JavaScript needed for performing client-side validation. | yii\validators\Validator |
createValidator() | Creates a validator object. | yii\validators\Validator |
detachBehavior() | Detaches a behavior from the component. | yii\base\Component |
detachBehaviors() | Detaches all behaviors from the component. | yii\base\Component |
ensureBehaviors() | Makes sure that the behaviors declared in behaviors() are attached to this component. | yii\base\Component |
getAttributeNames() | Returns cleaned attribute names without the ! character at the beginning. |
yii\validators\Validator |
getBehavior() | Returns the named behavior object. | yii\base\Component |
getBehaviors() | Returns all behaviors attached to this component. | yii\base\Component |
getClientOptions() | Returns the client-side validation options. | yii\validators\Validator |
getValidationAttributes() | Returns a list of attributes this validator applies to. | yii\validators\Validator |
hasEventHandlers() | Returns a value indicating whether there is any handler attached to the named event. | yii\base\Component |
hasMethod() | Returns a value indicating whether a method is defined. | yii\base\Component |
hasProperty() | Returns a value indicating whether a property is defined for this component. | yii\base\Component |
init() | {@inheritdoc} | yii\validators\DateValidator |
isActive() | Returns a value indicating whether the validator is active for the given scenario and attribute. | yii\validators\Validator |
isEmpty() | Checks if the given value is empty. | yii\validators\Validator |
off() | Detaches an existing event handler from this component. | yii\base\Component |
on() | Attaches an event handler to an event. | yii\base\Component |
trigger() | Triggers an event. | yii\base\Component |
validate() | Validates a given value. | yii\validators\Validator |
validateAttribute() | {@inheritdoc} | yii\mongodb\validators\MongoDateValidator |
validateAttributes() | Validates the specified object. | yii\validators\Validator |
Protected Methods
Method | Description | Defined By |
---|---|---|
formatMessage() | Formats a mesage using the I18N, or simple strtr if \Yii::$app is not available. |
yii\validators\Validator |
parseDateValue() | {@inheritdoc} | yii\mongodb\validators\MongoDateValidator |
validateValue() | {@inheritdoc} | yii\validators\DateValidator |
Constants
Constant | Value | Description | Defined By |
---|---|---|---|
TYPE_DATE | 'date' | Constant for specifying the validation $type as a date value, used for validation with intl short format. | yii\validators\DateValidator |
TYPE_DATETIME | 'datetime' | Constant for specifying the validation $type as a datetime value, used for validation with intl short format. | yii\validators\DateValidator |
TYPE_TIME | 'time' | Constant for specifying the validation $type as a time value, used for validation with intl short format. | yii\validators\DateValidator |
Property Details
The name of the attribute to receive the parsing result as \MongoDate instance. When this property is not null and the validation is successful, the named attribute will receive the parsing result as \MongoDate instance.
This can be the same attribute as the one being validated. If this is the case, the original value will be overwritten with the value after successful validation.
Method Details
{@inheritdoc}
protected void parseDateValue ( $value ) | ||
$value |
{@inheritdoc}
public void validateAttribute ( $model, $attribute ) | ||
$model | ||
$attribute |