-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add date type * feat: add arrays of dates * feat: dates are deserialised as Date objects
- Loading branch information
1 parent
6142fcc
commit 3096e64
Showing
14 changed files
with
185 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import SimpleType from './SimpleType.js'; | ||
|
||
export default class DateType extends SimpleType { | ||
static _type = 'string'; | ||
static _format = 'iso-date-time'; | ||
|
||
static isDate(possibleDate) { | ||
return possibleDate instanceof Date || !isNaN(new Date(possibleDate)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import DateType from './DateType.js'; | ||
import test from 'ava'; | ||
|
||
test('DateType is Date', t => { | ||
t.is(DateType.toString(), 'Date'); | ||
}); | ||
|
||
test('DateType is not required', t => { | ||
t.is(DateType._required, false); | ||
}); | ||
|
||
test('DateType does not have properties', t => { | ||
t.is(DateType._properties, undefined); | ||
}); | ||
|
||
test('DateType does not have items', t => { | ||
t.is(DateType._items, undefined); | ||
}); | ||
|
||
test('DateType is not a resolved type', t => { | ||
t.is(DateType._resolved, false); | ||
}); | ||
|
||
test('RequiredDateType is RequiredDate', t => { | ||
t.is(DateType.required.toString(), 'RequiredDate'); | ||
}); | ||
|
||
test('RequiredDateType is required', t => { | ||
t.is(DateType.required._required, true); | ||
}); | ||
|
||
test('RequiredDateType does not have properties', t => { | ||
t.is(DateType.required._properties, undefined); | ||
}); | ||
|
||
test('RequiredDateType does not have items', t => { | ||
t.is(DateType.required._items, undefined); | ||
}); | ||
|
||
test('RequiredDateType is not a resolved type', t => { | ||
t.is(DateType.required._resolved, false); | ||
}); |
Oops, something went wrong.