add iso 8601 duration action - #1102
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Thank you very much! It may take me a while to review this PR as it is very important to me to check the validation closely. I hope to get back to you next week. |
|
Yeah, this one is quite biggish. There's still also a question of whether 8601 (current), 8601-1 (allows to use Week designator with Year/Month/Day) or 8601-2 (allows +- before P, to determine if it's positive or negative value) should be supported. |
|
I will focus on reviewing and merging other actions first. If users want to see this PR merged, please give a 👍. |
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for ISO8601 durations by introducing a new action, issue, and corresponding type definitions along with documentation and tests.
- Added new API routes in the documentation for isoDuration actions and issues
- Created type definitions for IsoDurationIssue and IsoDurationAction in the API types folder
- Implemented the isoDuration action, its validation function, and added comprehensive tests
Reviewed Changes
Copilot reviewed 10 out of 18 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| website/src/routes/api/menu.md | Updated API menu with isoDuration and related entries |
| website/src/routes/api/(types)/IsoDurationIssue/properties.ts | Added property definitions for IsoDurationIssue |
| website/src/routes/api/(types)/IsoDurationAction/properties.ts | Added property definitions for IsoDurationAction |
| website/src/routes/api/(actions)/isoDuration/properties.ts | Added property definitions for the isoDuration action |
| library/src/actions/isoDuration/isoDuration.ts | Implemented the isoDuration action and overloads |
| library/src/actions/isoDuration/isoDuration.test.ts | Provided tests covering valid and invalid ISO duration cases |
| library/src/actions/isoDuration/isoDuration.test-d.ts | Added type tests for the isoDuration action |
| library/src/actions/isoDuration/isISO8601Duration.ts | Implemented the validation function for ISO8601 durations |
| library/src/actions/isoDuration/index.ts | Exported the isoDuration action |
| library/src/actions/index.ts | Included exports for the new isoDuration action |
Files not reviewed (8)
- website/src/routes/api/(actions)/isoDuration/index.mdx: Language not supported
- website/src/routes/api/(methods)/pipe/index.mdx: Language not supported
- website/src/routes/api/(schemas)/any/index.mdx: Language not supported
- website/src/routes/api/(schemas)/custom/index.mdx: Language not supported
- website/src/routes/api/(schemas)/string/index.mdx: Language not supported
- website/src/routes/api/(schemas)/unknown/index.mdx: Language not supported
- website/src/routes/api/(types)/IsoDurationAction/index.mdx: Language not supported
- website/src/routes/api/(types)/IsoDurationIssue/index.mdx: Language not supported
commit: |
|
This schema is very niche, and I wouldn’t expect many people to need it. This is more of to have better compatibility with JSON Schemas. with that in mind, this PR misses adjustments for to-json-schema package, so that this gets transformed to string’s format. Same for |
|
I will try to release it with Valibot v1.2 |
|
@muningis Hi. Are you interested in refining this PR? Hi. Are you interested in refining this PR? I see you've created a complex function with 7 regexps that thoroughly validates duration. This is quite verbose; our library is aimed at reducing bundle size and speed. Could we use a more flexible and common validation, a single regular expression? Yes, it won't be as precise, but I think it's good enough. https://github.com/ajv-validator/ajv-formats/blob/master/src/formats.ts#L54 Link #1497 And please fix conflicts |
ISO8601 Duration (https://en.wikipedia.org/wiki/ISO_8601#Durations) - used (primarly) by
string()schema