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.DateTimeValidator(data);
if (false === validator.isValid()) {
validator.errors().first();
}
Extends
Members
-
data * inherited
-
Data that needs to be validated.
-
This option allows to validate a custom date format.
Default: "
YYYY-MM-DD HH:mm:ss"Year, month, and day tokens
Tokens are case-sensitive.
Input Example Description YYYY20144 or 2 digit year YY142 digit year Y-25Year with any number of digits and sign Q1..4Quarter of year. Sets month to first month in quarter. M MM1..12Month number MMM MMMMJan..DecemberMonth name in locale that is specified D DD1..31Day of month Do1st..31stDay of month with ordinal DDD DDDD1..365Day of year X1410715640.579Unix timestamp x1410715640579Unix ms timestamp Week year, week, and weekday tokens
Tokens are case-sensitive.
Input Example Description gggg2014Locale 4 digit week year gg14Locale 2 digit week year w ww1..53Locale week of year e0..6Locale day of week ddd ddddMon...SundayDay name in locale that is specified GGGG2014ISO 4 digit week year GG14ISO 2 digit week year W WW1..53ISO week of year E1..7ISO day of week Locale aware formats
Tokens are case-sensitive.
Input Example Description L04/09/1986Date (in local format) LLSeptember 4 1986Month name, day of month, year LLLSeptember 4 1986 8:30 PMMonth name, day of month, year, time LLLLThursday, September 4 1986 8:30 PMDay of week, month name, day of month, year, time LT08:30 PMTime (without seconds) LTS08:30:00 PMTime (with seconds) Hour, minute, second, millisecond, and offset tokens
Tokens are case-sensitive.
Input Example Description H HH0..23Hours (24 hour time) h hh1..12Hours (12 hour time used with a A.)k kk1..24Hours (24 hour time from 1 to 24) a Aam pmPost or ante meridiem (Note the one character a pare also considered valid)m mm0..59Minutes s ss0..59Seconds S SS SSS0..999Fractional seconds Z ZZ+12:00Offset from UTC as +-HH:mm,+-HHmm, orZ -
lang String inherited
-
Language of error messages.
-
This message is shown if the underlying data is not a valid datetime.
Default: "This value is not a valid datetime."
You can use the following parameters in this message:
Parameter Description %%value%%The current (invalid) value
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