Create a new Validator.
| Name | Type | Description |
|---|---|---|
data |
* | The data which needs to be validated. |
options |
Object | The setting options |
optionRules |
Object | The validation rules for setting options. |
lang |
String |
The language used by the application. Default: "en". |
internal |
Boolean | If this parameter is true, it means, that validation called from core. |
Properties:
| Name | Type | Description |
|---|---|---|
alias |
Array | The aliases for the current validator. They could be used in the short validation format. Defined aliases: [' |
options |
Object | The description of the required options. |
Example
var validator = new sogv.EmailValidator(data, {data: 'loose'});
if (false === validator.isValid()) {
validator.errors().first();
}
Extends
Members
-
data * inherited
-
Data that needs to be validated.
-
lang String inherited
-
Language of error messages.
-
This message is shown if the underlying data is not a valid email address.
Default: "
This value is not a valid email address."You can use the following parameters in this message:
Parameter Description %%value%%The current (invalid) value -
This option is optional and defines the pattern the
emailaddress is validated against.Default: '
html5'Valid values are:
- loose - A simple regular expression. Allows all values with an "@" symbol in, and a "." in the second host part of the email address.
- html5 - This matches the pattern used for the HTML5 email input element.
-
Normalizer string before validate (trim, etc.).
Default:
false
Methods
-
errors ()sogv.Error inherited
-
Return error errors
Returns:
Type Description sogv.Error Error messages -
Check if data valid.
Returns:
Type Description Boolean Validation status