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.CardSchemeValidator(data, schemes);
if (false === validator.isValid()) {
validator.errors().first();
}
Extends
Members
-
data * inherited
-
Data that needs to be validated.
-
lang String inherited
-
Language of error messages.
-
The message shown when the value does not pass the CardScheme check.
Default: "Unsupported card type or invalid card number."
You can use the following parameters in this message:
Parameter Description %%value%%The current (invalid) value -
This option is required and represents the name of the number scheme used to validate the credit card number, it can either be a string or an array.
Valid values are:
- AMEX
- CHINA_UNIONPAY
- DINERS
- DISCOVER
- INSTAPAYMENT
- JCB
- LASER
- MAESTRO
- MASTERCARD
- MIR
- UATP
- VISA
For more information about the used schemes, see Wikipedia: Issuer identification number (IIN).
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