fix: date-time string validation to fail validating for date-only strings instead of throwing a TypeError

master
Victor Emanouilov 2016-08-04 13:49:53 +03:00
parent af1f77166d
commit 6df7b2040b
2 changed files with 18 additions and 0 deletions

View File

@ -90,6 +90,8 @@ function date(str) {
function time(str, full) {
if (str === undefined) return false;
var matches = str.match(TIME);
if (!matches) return false;

View File

@ -100,6 +100,22 @@
}
]
},
{
"description": "validation of date-time strings",
"schema": {"format": "date-time"},
"tests": [
{
"description": "a valid date-time string",
"data": "1963-06-19T12:13:14Z",
"valid": true
},
{
"description": "an invalid date-time string",
"data": "1963-06-19",
"valid": false
}
]
},
{
"description": "validation of uuid strings",
"schema": {"format": "uuid"},