gcanti / io-ts-types

A collection of codecs and combinators for use with io-ts
https://gcanti.github.io/io-ts-types/
MIT License
311 stars 40 forks source link

DateFromISOString accepts invalid ISO strings #126

Open Kinrany opened 4 years ago

Kinrany commented 4 years ago

🐛 Bug report

Current Behavior

DateFromISOString accepts any string that can be parsed by new Date(s)

Expected behavior

DateFromISOString accepts only ISO strings

Reproducible example

DateFromISOString.decode('6 Mar 17 21:22 UT')

Suggested solution(s)

Rename into DateFromString and add a note that this codec is implemented using Date.parse()

Your environment

Which versions of io-ts-types are affected by this issue? Did this work in previous versions of io-ts-types?

Software Version(s)
fp-ts 2.5.3
io-ts 2.1.2
io-ts-types 0.5.6
TypeScript 3.8.3
giogonzo commented 4 years ago

I guess we could add a deprecation notice, + the new DateFromString codec, + maybe also the new DateFromISOString2v (second version) codec working as expected above

OliverJAsh commented 4 years ago

@giogonzo

the new DateFromString codec, + maybe also the new DateFromISOString2v (second version) codec

Hey! Could you elaborate? I'm not sure where to find either of the things you mentioned.

giogonzo commented 4 years ago

@OliverJAsh hi, it was just a proposal for the "fix" here, still to do :)

Next minor release:

Next major release