Skip to content

fix: accept fractional seconds in ISO durations - #3156

Open
agammann wants to merge 1 commit into
hapijs:masterfrom
agammann:fix-duration-fractional-seconds
Open

agammann wants to merge 1 commit into
hapijs:masterfrom
agammann:fix-duration-fractional-seconds

Conversation

@agammann

Copy link
Copy Markdown

Joi.string().isoDuration() rejects PT4.4S, the example reported in #2612. Allow a fractional seconds component using either a decimal point or comma, requiring digits on both sides of the separator.

Add valid cases for both separators, milliseconds, and a duration with larger components. Add rejection cases for missing digits, repeated separators, and components placed after seconds. This change covers fractional seconds only; fractions of larger units remain outside this patch.

Validation on Node.js 24.19.0: the duration validation test fails before the change. npm test passes afterward: 1,838 tests, 100% coverage, lint, types, and leak checks.

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

Successfully merging this pull request may close these issues.

1 participant