Skip to content

feat(schema): implement Phase 12 String Format Schemas#23

Merged
viniciusdacal merged 1 commit intomainfrom
feat/schema-phase12-string-formats
Feb 6, 2026
Merged

feat(schema): implement Phase 12 String Format Schemas#23
viniciusdacal merged 1 commit intomainfrom
feat/schema-phase12-string-formats

Conversation

@viniciusdacal
Copy link
Copy Markdown
Contributor

Summary

  • 16 format schemas: email, uuid, url, hostname, ipv4, ipv6, base64, hex, jwt, cuid, ulid, nanoid, iso.date, iso.time, iso.datetime, iso.duration
  • FormatSchema base class extracted by code simplifier — shared _parse, _toJSONSchema, and _clone logic. Subclasses only implement _validate(), _errorMessage, and optionally _jsonSchemaExtra()
  • Code review fixes: ISO date validation now uses Date constructor for proper calendar validation (rejects Feb 31, non-leap-year Feb 29). IPv4 rejects leading zeros in octets
  • 228 tests passing (47 new)

Test plan

  • Email: valid/invalid, StringSchema inheritance, JSON Schema format
  • UUID: valid v4, invalid, JSON Schema format
  • URL: valid http/https, invalid, JSON Schema format "uri"
  • Hostname: valid, invalid (leading dash), JSON Schema format
  • IPv4: valid (0.0.0.0, 255.255.255.255), out-of-range, leading zeros rejected
  • IPv6: full, abbreviated, ::1, invalid
  • Base64: valid, length % 4 check, contentEncoding
  • Hex: valid, non-hex rejected
  • JWT: valid 3-segment, invalid
  • CUID: valid c-prefix, invalid
  • ULID: valid 26-char Crockford, invalid
  • Nanoid: valid 21-char, invalid
  • ISO date: valid, month/day range, impossible dates (Feb 31, non-leap Feb 29)
  • ISO time: valid, hour/minute/second range
  • ISO datetime: valid with timezone, invalid
  • ISO duration: valid, bare P rejected
  • Email ReDoS: adversarial input completes < 100ms
  • Full test suite: 228 tests passing

🤖 Generated with Claude Code

Add 16 format schemas: email, uuid, url, hostname, ipv4, ipv6,
base64, hex, jwt, cuid, ulid, nanoid, iso.date, iso.time,
iso.datetime, iso.duration. Extracted FormatSchema base class for
shared validation pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor Author

@viniciusdacal viniciusdacal left a comment

Choose a reason for hiding this comment

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

Code Review — Phase 12: String Format Schemas

Overview

Adds 16 format schema validators with a shared FormatSchema base class. All extend StringSchema and add format-specific validation.

Architecture

  • FormatSchema base (format-schema.ts) — excellent extraction. Subclasses only need _validate(), _errorMessage, and optionally _jsonSchemaExtra(). The generic _clone() using this.constructor eliminates boilerplate across all 16 schemas.
  • Each format file is 11-17 lines. Clean separation of concerns.

Validation Quality

  • Email: RFC 5322 simplified regex, tested for ReDoS — completes adversarial input in < 100ms
  • UUID: Case-insensitive, standard format
  • URL: Native URL constructor — safe, standards-compliant
  • IPv4: Regex with octet range check AND leading zero rejection (fixed during review)
  • IPv6: Comprehensive regex covering full, abbreviated, link-local, and mapped-IPv4 forms
  • ISO dates: Proper calendar validation using Date constructor (fixed during review — rejects Feb 31, non-leap Feb 29)
  • Base64: Regex + length % 4 check
  • ID formats (cuid, ulid, nanoid): Correct character sets and lengths

Issues Fixed During Review

  1. ISO date accepted impossible dates (Feb 31, Apr 31) — fixed with Date constructor validation
  2. IPv4 accepted leading zeros (001.002.003.004) — fixed with stricter regex

No remaining blocking issues.

Verdict: Approve

@viniciusdacal viniciusdacal merged commit d7a36b7 into main Feb 6, 2026
@viniciusdacal viniciusdacal deleted the feat/schema-phase12-string-formats branch February 6, 2026 16:34
viniciusdacal added a commit that referenced this pull request Feb 22, 2026
Add 16 format schemas: email, uuid, url, hostname, ipv4, ipv6,
base64, hex, jwt, cuid, ulid, nanoid, iso.date, iso.time,
iso.datetime, iso.duration. Extracted FormatSchema base class for
shared validation pattern.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
viniciusdacal added a commit that referenced this pull request Apr 5, 2026
…2053)

Phase 1 of runtime feature parity tests:
- Test skeleton: main.rs, common.rs (shared helpers), checklist_meta.rs (report validation)
- HTTP serving tests: API delegation (#5), proxy rules (#6), logging middleware (#7)
- Compilation tests: import.meta.env (#19), CSS→JS (#20), tsconfig paths (#22),
  /@deps endpoint (#23), /@css endpoint (#24), theme CSS injection (#25)
- PARITY_REPORT.md with all 55 included + 12 deferred feature rows
- Test fixtures: env-app, css-app, tsconfig-paths-app, theme-app

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
viniciusdacal added a commit that referenced this pull request Apr 5, 2026
* test(runtime): add Phase 1 parity tests — infra, HTTP, compilation (#2053)

Phase 1 of runtime feature parity tests:
- Test skeleton: main.rs, common.rs (shared helpers), checklist_meta.rs (report validation)
- HTTP serving tests: API delegation (#5), proxy rules (#6), logging middleware (#7)
- Compilation tests: import.meta.env (#19), CSS→JS (#20), tsconfig paths (#22),
  /@deps endpoint (#23), /@css endpoint (#24), theme CSS injection (#25)
- PARITY_REPORT.md with all 55 included + 12 deferred feature rows
- Test fixtures: env-app, css-app, tsconfig-paths-app, theme-app

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test(runtime): add Phase 2 parity tests — SSR, HMR, watcher, module graph (#2053)

Phase 2 of runtime feature parity tests:
- SSR: verify SSR-enabled server serves HTML shell for page routes (#34)
- HMR Tier 1: WebSocket update message delivery via hmr_hub.broadcast (#37)
- HMR Tier 1: CSS-only update message (not full-reload) (#38)
- HMR Tier 2: FileWatcher detects entry file changes in tempdir (#39)
- Module graph: transitive dependency invalidation A→B→C (#40)
- Shared helpers: copy_fixture() for tempdir-based watcher tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test(runtime): add Phase 3 parity tests — errors, diagnostics, MCP, auto features (#2053)

Phase 3 of runtime feature parity tests:
- Error overlay: client error reporting via POST endpoint (#47)
- Console log: ring buffer endpoint returns stored entries (#50)
- MCP: Streamable HTTP responds to tools/list with 7 registered tools (#51)
- MCP: tool invocation returns diagnostics result (#52)
- MCP: events WebSocket delivers initial server status (#53)
- Auto-install: blacklist/dedup coordination logic (#54)
- Dep watcher: detects file changes in linked package dist/ (#55)

All 22 parity tests passing. Full cargo test --all clean. Clippy clean.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(runtime): address review findings in parity tests (#2053)

- Fix ~25 incorrect EXISTING test location references in PARITY_REPORT.md
  to match actual function names in static_serving.rs, client_render.rs,
  ssr_render.rs, and error_overlay.rs
- Rename misleading ssr_redirect_returns_302_with_location_header to
  ssr_enabled_server_returns_html_shell_for_page_routes (test asserts 200,
  not 302)
- Add import.meta.env.SECRET_KEY reference to env-app fixture so the
  non-public env var assertion actually validates the code path

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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