mysql-validator
Version:
MySql data type validation.
51 lines (49 loc) • 1.22 kB
JavaScript
exports.TEST = {
date: {
valid: [
// YYYY-MM-DD, YY-MM-DD, YYYYMMDD, YYMMDD
'2012-11-02', '12-11-02', '20121102', '121102',
// separator
'2012~`!@#$%^&*()-_=+{}[]\\|:;<>,.?/11---02', // without " ' space
// single value for month/day
'2012-11-2',
// after date
'2012-11-02 w', '12-11-02 w', '2012-11-02w', '12-11-02w',
// days in month
'2012-02-28', '2012-02-29', '2012-11-30',
'12-02-28', '12-02-29', '12-11-30',
'20120228', '20120229', '20121130',
'120228', '120229', '121130'
],
invalid: [
// separator
'2012w11aa02', '2012-1102',
'2012*11 02', '2012 11 02',
// out of range
'20122-11-02', '2012-13-02', '2012-11-32',
'201221102', '20121302', '20121132',
// single value for month/day
'2012112',
// after date
'20121102w', '121102w', '20121102 w', '121102 w',
// days in month
'2012-02-30', '2012-11-31',
'12-02-30', '12-11-31',
'20120230', '20121131',
'120230', '121131'
],
},
year: {
valid: [
// Y|YY
'0', '00', '1', '69', '70', '99',
// YYYY
'1901', '2155',
// at the end
'2012w', '2012 w', '2012~`!@#$%^&*()-_=+{}[]\\|:;<>,.?/'
],
invalid: [
'-1', '9999', '1900', '2156', 'w'
]
}
}