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

feat: Validate ISO timestamps with offsets #496

Conversation

macarie
Copy link
Contributor

@macarie macarie commented Mar 28, 2024

I've added a bunch of tests with both valid and invalid timestamps and updated the JSDoc to list all the allowed formats.

The regex is relatively permissive as it allows for any number in the offset. If something stricter is required, I can work on it, but I'm afraid it would explode in complexity. For example, a 00:00 offset is valid only if preceded by a + and not by -; the maximum offset should be ±12:00, etc.

Closes #495.

@fabian-hiller fabian-hiller self-assigned this Mar 29, 2024
@fabian-hiller fabian-hiller added the enhancement New feature or request label Mar 29, 2024
@fabian-hiller
Copy link
Owner

Thank you for creating this PR. Since I am currently busy rewriting the library based on #463, it may take some time before I release the next version. So I don't recommend to wait and use the regex function instead or add a custom isoTimestamp action to your own codebase.

@macarie
Copy link
Contributor Author

macarie commented Mar 29, 2024

Sure, no problem! 😄

Copy link
Contributor

@brandonpittman brandonpittman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get this released.

@mxdvl
Copy link
Contributor

mxdvl commented Apr 15, 2024

Would you like me to port this changes as part of #502?

This would technically be a breaking change, as inputs that would previously throw an error may now pass, so bundling it with other breaking changes might be appropriate.

@macarie
Copy link
Contributor Author

macarie commented Apr 15, 2024

@mxdvl, sure, but I also have some time now.

I can close this PR and implement isoTimestamp for #502 (and maybe some other related iso* validators) if that's okay with y'all 🙂

@fabian-hiller
Copy link
Owner

Feel free to contribute to #502, but don't go crazy, because I don't want to spend too much time on new features. I want to get the next version out as soon as possible. Until v1, breaking changes are ok.

@fabian-hiller
Copy link
Owner

Thank you! Merged in #530.

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

Successfully merging this pull request may close these issues.

isoTimestamp only accepts UTC timestamps
4 participants