Skip to content

Commit

Permalink
Make Date type not break.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukesneeringer committed Jun 30, 2016
1 parent 4dce1c5 commit 5fb57f9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/typed.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ Typed.Boolean = Typed("Boolean", value =>
value === false ? false :
TypeError(`"${value}" is not a boolean`))

Typed.Date = Typed("Date", value => {
var d = new Date(value)
if (isNaN(d.valueOf())) {
return new TypeError(`"${value}" is not a valid date.`)
}
return d
})


class MaybeType extends Type {
constructor(type) {
super()
Expand Down

0 comments on commit 5fb57f9

Please sign in to comment.