Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateFromISOString accepts invalid ISO strings #126

Open
Kinrany opened this issue Apr 2, 2020 · 3 comments
Open

DateFromISOString accepts invalid ISO strings #126

Kinrany opened this issue Apr 2, 2020 · 3 comments

Comments

@Kinrany
Copy link

Kinrany commented Apr 2, 2020

🐛 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
Copy link
Contributor

giogonzo commented Apr 3, 2020

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
Copy link
Contributor

@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
Copy link
Contributor

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

Next minor release:

  • add DateFromISOString2v using Date.parse
  • add deprecation notice on the current DateFromISOString (in favor of 2v)

Next major release

  • drop the current DateFromISOString
  • rename the updated one removing the 2v suffix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants