Skip to content

Commit

Permalink
add ISO 8601 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ravestack committed Sep 27, 2015
1 parent ff4d907 commit 4beed24
Showing 1 changed file with 58 additions and 3 deletions.
61 changes: 58 additions & 3 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -854,24 +854,79 @@ describe('Validators', function () {
test({
validator: 'isDate'
, valid: [
//NOTE: null pass as well in the regular function, but fails in the test suite
'2011-08-04'
, '2011-09-30'
, '04. 08. 2011.'
, '08/04/2011'
, '08/31/2011'
, '2011.08.04'
, '4. 8. 2011. GMT'
, '2011-08-04 12:00'
, '2/29/24'
, '2-29-24'
, '4. 8. 2011. GMT'
, '2. 28. 2011. GMT'
, '2. 29. 2008. GMT'
, '2011-08-04 12:00'
, '2/22/23'
, '2-23-22'
, '12'
, '11/2/23 12:24'
, new Date()
, 'Mon Aug 17 2015 00:24:56 GMT-0500 (CDT)'
, '2/22/23 23:24:26'
]
//valid ISO 8601 dates below
, '2009-12T12:34'
, '2009'
, '2009-05-19'
, '2009-05-19'
, '2009-05'
, '2009-001'
, '2009-05-19'
, '2009-05-19 00:00'
, '2009-05-19 14:31'
, '2009-05-19 14:39:22'
, '2009-05-19T14:39Z'
, '2009-05-19 14:39:22-06:00'
, '2009-05-19 14:39:22+0600'
, '2009-05-19 14:39:22-01'
, '2007-04-06T00:00'
, '2010-02-18T16:23:48.5'
, '200905'
, '2009-'
, '2009-05-19 14:'
, '200912-01'
]
, invalid: [
'foo'
, '2011-foo-04'
, '2011-09-31'
, '2. 29. 1987. GMT'
, '2. 29. 2011. GMT'
, '2/29/25'
, '2-29-25'
, 'GMT'
//invalid ISO 8601 dates below
, '2009367'
, '2007-04-05T24:50'
, '2009-000'
, '2009-M511'
, '2009M511'
, '2009-05-19T14a39r'
, '2009-05-19T14:3924'
, '2009-0519'
, '2009-05-1914:39'
, '2009-05-19r14:39'
, '2009-05-19 14a39a22'
, '2009-05-19 14:39:22+06a00'
, '2009-05-19 146922.500'
, '2010-02-18T16.5:23.35:48'
, '2010-02-18T16:23.35:48'
, '2010-02-18T16:23.35:48.45'
, '2009-05-19 14.5.44'
, '2010-02-18T16:23.33.600'
, '2010-02-18T16,25:23:48,444'
, '2009-02-30 14:'
, '200912-32'
]
});
});
Expand Down

0 comments on commit 4beed24

Please sign in to comment.