Skip to content

add iso 8601 duration action #1102

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

muningis
Copy link
Contributor

ISO8601 Duration (https://en.wikipedia.org/wiki/ISO_8601#Durations) - used (primarly) by string() schema

Copy link

vercel bot commented Mar 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
valibot ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 23, 2025 4:01pm

@fabian-hiller
Copy link
Owner

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.

@muningis
Copy link
Contributor Author

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.

@fabian-hiller
Copy link
Owner

I will focus on reviewing and merging other actions first. If users want to see this PR merged, please give a 👍.

@fabian-hiller fabian-hiller requested a review from Copilot April 20, 2025 00:31
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

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

Copy link

pkg-pr-new bot commented Apr 20, 2025

Open in StackBlitz

npm i https://pkg.pr.new/valibot@1102

commit: 5d05997

@muningis
Copy link
Contributor Author

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 minEntries and maxEntries.

@fabian-hiller fabian-hiller added this to the v1.2 milestone Apr 22, 2025
@fabian-hiller
Copy link
Owner

I will try to release it with Valibot v1.2

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.

2 participants