This guide section doesn't describe how validation works but instead describes all Yii validators and their parameters.
In order to learn model validation basics please refer to [Model, Validation subsection](model.md#Validation).
As a model both represents data and defines the business rules to which that data must adhere, comprehending data validation is key to using Yii. In order to learn model validation basics, please refer to [Model, Validation subsection](model.md#Validation).
This guide describes all of Yii's validators and their parameters.
Standard Yii validators
-----------------------
Standard Yii validators could be specified using aliases instead of referring to class names. Here's the list of all
validators bundled with Yii with their most useful properties:
The standard Yii validators are defined in many Yii classes, found primarily within the `yii\validators` namespace. But you do not need to specify the full namespace for the standard Yii validators as Yii can recognize them from defined aliases.
Here's the list of all validators bundled with the Yii framework, including their most useful properties. The default value for each property is indicated in parentheses. Note that this does not present an exhaustive list of each validator's properties.
Validates that the attribute value is a valid email address.
Validates that the attribute value is a valid email address. By default, this validator checks if the attribute value is a syntactical valid email address, but the validator can be configured to check the address's domain for the address's existence.
-`allowName` whether to allow name in the email address (e.g. `John Smith <john.smith@example.com>`). _(false)_.
-`checkMX` whether to check the MX record for the email address. _(false)_
-`checkPort` whether to check port 25 for the email address. _(false)_
-`enableIDN` whether validation process should take into account IDN (internationalized domain names). _(false)_
-`allowName`, whether to allow the name in the email address (e.g. `John Smith <john.smith@example.com>`). _(false)_.
-`checkMX`, whether to check the MX record for the email address. _(false)_
-`checkPort`, whether to check port 25 for the email address. _(false)_
-`enableIDN`, whether the validation process should take into account IDN (internationalized domain names). _(false)_
Validates that the attribute value is a valid http or https URL.
-`validSchemes` list of URI schemes which should be considered valid. _['http', 'https']_
-`defaultScheme` the default URI scheme. If the input doesn't contain the scheme part, the default scheme will be
-`validSchemes`, an array of URI schemes that should be considered valid. _['http', 'https']_
-`defaultScheme`, the default URI scheme. If the input doesn't contain the scheme part, the default scheme will be
prepended to it. _(null)_
-`enableIDN` whether validation process should take into account IDN (internationalized domain names). _(false)_
-`enableIDN`, whether the validation process should take into account IDN (internationalized domain names). _(false)_
Validating values out of model context
--------------------------------------
Sometimes you need to validate a value that is not bound to any model such as email. In Yii `Validator` class has
`validateValue` method that can help you with it. Not all validator classes have it implemented but the ones that can
operate without model do. In our case to validate an email we can do the following:
Sometimes you need to validate a value that is not bound to any model, such as a standalone email address. The `Validator` class has a
`validateValue` method that can help you in these scenarios. Not all validator classes have implemented this method, but the ones that have implemented `validateValue` can be used without a model. For example, to validate an email stored in a string, you can do the following: