Skip to content

Commit

Permalink
Merge pull request #22 from lukesneeringer/master
Browse files Browse the repository at this point in the history
Make Date type not break.
  • Loading branch information
lukesneeringer committed Jul 19, 2016
2 parents 3460ddb + 5fb57f9 commit a44c2da
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 a44c2da

Please sign in to comment.