Skip to content

feat: RFC 3339 time Validator#1556

Open
hazrid93 wants to merge 1 commit into
open-circle:mainfrom
hazrid93:hazrid93/29_1496
Open

feat: RFC 3339 time Validator#1556
hazrid93 wants to merge 1 commit into
open-circle:mainfrom
hazrid93:hazrid93/29_1496

Conversation

@hazrid93

@hazrid93 hazrid93 commented Jul 20, 2026

Copy link
Copy Markdown

Closes #1496.

Add an rfc3339Time(message?) action that validates HH:MM:SS with optional fractional seconds (.\d+) and an optional offset (Z or +/ HH:MM), e.g. 14:30:00, 14:30:00Z, 14:30:00.123 05:00. Unlike isoTime it requires seconds; unlike isoTimeSecond it accepts offsets and fractional seconds.

Summary by CodeRabbit

  • New Features
    • Added RFC 3339 time validation for values formatted as HH:MM:SS, with optional fractional seconds and timezone information.
    • Supports custom validation error messages.
    • Exported the new validator through the public actions library.

Closes open-circle#1496.

Add an `rfc3339Time(message?)` action that validates `HH:MM:SS` with optional fractional seconds (`.\d+`) and an optional offset (`Z` or `+/ HH:MM`), e.g. `14:30:00`, `14:30:00Z`, `14:30:00.123 05:00`. Unlike isoTime it requires seconds; unlike isoTimeSecond it accepts offsets and fractional seconds.
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels Jul 20, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Adds an RFC 3339 time validation action supporting fractional seconds and UTC or offset time zones. The action defines validation issue and action contracts, provides overloads for optional custom messages, performs synchronous validation of typed values, and records mismatches. New barrel exports expose the action through its entrypoint and the main actions index.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly names the new RFC 3339 time validator and matches the main code change.
Linked Issues check ✅ Passed The new rfc3339Time action supports required seconds, optional fractions, and UTC/offset zones as requested.
Out of Scope Changes check ✅ Passed The change set stays focused on adding the RFC 3339 time validator and barrel exports, with no unrelated code.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@library/src/actions/rfc3339Time/rfc3339Time.ts`:
- Around line 59-65: Remove the JSDoc comment immediately preceding the overload
in the RFC 3339 time action declarations, while preserving the documentation on
the first overload and leaving the overload signatures unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: abb3777a-f9c0-4d61-9a5a-467dd8d70b3a

📥 Commits

Reviewing files that changed from the base of the PR and between 90bc2c7 and a3feb03.

📒 Files selected for processing (3)
  • library/src/actions/index.ts
  • library/src/actions/rfc3339Time/index.ts
  • library/src/actions/rfc3339Time/rfc3339Time.ts

Comment on lines +59 to +65
/**
* Creates an RFC 3339 time validation action.
*
* @param message The error message.
*
* @returns An RFC 3339 time action.
*/

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Remove the JSDoc comment for this overload.

As per coding guidelines, JSDoc should only be provided on the first overload for overload sets.

♻️ Proposed fix
-/**
- * Creates an RFC 3339 time validation action.
- *
- * `@param` message The error message.
- *
- * `@returns` An RFC 3339 time action.
- */
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/**
* Creates an RFC 3339 time validation action.
*
* @param message The error message.
*
* @returns An RFC 3339 time action.
*/
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@library/src/actions/rfc3339Time/rfc3339Time.ts` around lines 59 - 65, Remove
the JSDoc comment immediately preceding the overload in the RFC 3339 time action
declarations, while preserving the documentation on the first overload and
leaving the overload signatures unchanged.

Source: Coding guidelines

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

3 issues found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="library/src/actions/rfc3339Time/rfc3339Time.ts">

<violation number="1" location="library/src/actions/rfc3339Time/rfc3339Time.ts:13">
P2: The RFC_3339_TIME_REGEX is defined locally in this file instead of in the shared `src/regex.ts` module. Every other validation regex in this codebase (ISO_TIME_REGEX, ISO_TIME_SECOND_REGEX, UUID_REGEX, ULID_REGEX, SLUG_REGEX, etc.) is defined in `src/regex.ts` and imported by the action file. Defining it here instead of in `regex.ts` breaks the project convention, makes the regex harder to reuse (e.g. in a future `rfc3339DateTime` action), and is inconsistent with how `isoTime` and `isoTimeSecond` handle their regex patterns.</violation>

<violation number="2" location="library/src/actions/rfc3339Time/rfc3339Time.ts:14">
P2: Valid RFC 3339 leap-second times such as `23:59:60Z` are rejected because the seconds group only permits `00`–`59`. Accept the `60` form (or explicitly document and test an intentional non-RFC restriction).</violation>
</file>

<file name="library/src/actions/index.ts">

<violation number="1" location="library/src/actions/index.ts:94">
P3: The new public action is exported without runtime or type tests, leaving valid offsets/fractions, invalid values, and overload typing unverified before publication. Adding the matching test files would keep this action aligned with the existing validator coverage convention.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

* offset (`Z` or `+/-HH:MM`). See issue #1496.
*/
const RFC_3339_TIME_REGEX: RegExp =
/^([01]\d|2[0-3]):[0-5]\d:[0-5]\d(\.\d+)?(Z|[+-]([01]\d|2[0-3]):[0-5]\d)?$/u;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Valid RFC 3339 leap-second times such as 23:59:60Z are rejected because the seconds group only permits 0059. Accept the 60 form (or explicitly document and test an intentional non-RFC restriction).

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At library/src/actions/rfc3339Time/rfc3339Time.ts, line 14:

<comment>Valid RFC 3339 leap-second times such as `23:59:60Z` are rejected because the seconds group only permits `00`–`59`. Accept the `60` form (or explicitly document and test an intentional non-RFC restriction).</comment>

<file context>
@@ -0,0 +1,90 @@
+ * offset (`Z` or `+/-HH:MM`). See issue #1496.
+ */
+const RFC_3339_TIME_REGEX: RegExp =
+  /^([01]\d|2[0-3]):[0-5]\d:[0-5]\d(\.\d+)?(Z|[+-]([01]\d|2[0-3]):[0-5]\d)?$/u;
+
+/**
</file context>
Suggested change
/^([01]\d|2[0-3]):[0-5]\d:[0-5]\d(\.\d+)?(Z|[+-]([01]\d|2[0-3]):[0-5]\d)?$/u;
/^([01]\d|2[0-3]):[0-5]\d:(?:[0-5]\d|60)(\.\d+)?(Z|[+-]([01]\d|2[0-3]):[0-5]\d)?$/u;

* `HH:MM:SS` with optional fractional seconds and an optional UTC or numeric
* offset (`Z` or `+/-HH:MM`). See issue #1496.
*/
const RFC_3339_TIME_REGEX: RegExp =

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: The RFC_3339_TIME_REGEX is defined locally in this file instead of in the shared src/regex.ts module. Every other validation regex in this codebase (ISO_TIME_REGEX, ISO_TIME_SECOND_REGEX, UUID_REGEX, ULID_REGEX, SLUG_REGEX, etc.) is defined in src/regex.ts and imported by the action file. Defining it here instead of in regex.ts breaks the project convention, makes the regex harder to reuse (e.g. in a future rfc3339DateTime action), and is inconsistent with how isoTime and isoTimeSecond handle their regex patterns.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At library/src/actions/rfc3339Time/rfc3339Time.ts, line 13:

<comment>The RFC_3339_TIME_REGEX is defined locally in this file instead of in the shared `src/regex.ts` module. Every other validation regex in this codebase (ISO_TIME_REGEX, ISO_TIME_SECOND_REGEX, UUID_REGEX, ULID_REGEX, SLUG_REGEX, etc.) is defined in `src/regex.ts` and imported by the action file. Defining it here instead of in `regex.ts` breaks the project convention, makes the regex harder to reuse (e.g. in a future `rfc3339DateTime` action), and is inconsistent with how `isoTime` and `isoTimeSecond` handle their regex patterns.</comment>

<file context>
@@ -0,0 +1,90 @@
+ * `HH:MM:SS` with optional fractional seconds and an optional UTC or numeric
+ * offset (`Z` or `+/-HH:MM`). See issue #1496.
+ */
+const RFC_3339_TIME_REGEX: RegExp =
+  /^([01]\d|2[0-3]):[0-5]\d:[0-5]\d(\.\d+)?(Z|[+-]([01]\d|2[0-3]):[0-5]\d)?$/u;
+
</file context>

export * from './regex/index.ts';
export * from './returns/index.ts';
export * from './rfcEmail/index.ts';
export * from './rfc3339Time/index.ts';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: The new public action is exported without runtime or type tests, leaving valid offsets/fractions, invalid values, and overload typing unverified before publication. Adding the matching test files would keep this action aligned with the existing validator coverage convention.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At library/src/actions/index.ts, line 94:

<comment>The new public action is exported without runtime or type tests, leaving valid offsets/fractions, invalid values, and overload typing unverified before publication. Adding the matching test files would keep this action aligned with the existing validator coverage convention.</comment>

<file context>
@@ -91,6 +91,7 @@ export * from './reduceItems/index.ts';
 export * from './regex/index.ts';
 export * from './returns/index.ts';
 export * from './rfcEmail/index.ts';
+export * from './rfc3339Time/index.ts';
 export * from './safeInteger/index.ts';
 export * from './size/index.ts';
</file context>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: RFC 3339 time Validator

1 participant