Skip to content

fix(ack): align numeric validation across platforms - #130

Merged
leoafarias merged 2 commits into
mainfrom
codex/fix-numeric-platform-parity
Sep 1, 2026
Merged

fix(ack): align numeric validation across platforms#130
leoafarias merged 2 commits into
mainfrom
codex/fix-numeric-platform-parity

Conversation

@kauandotnet

@kauandotnet kauandotnet commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Normalize losslessly representable JSON numeric inputs consistently across Dart VM and JavaScript, including SchemaType inference and safe-integer boundary handling.
  • Make exported deep numeric equality and hashing platform-stable while retaining the dedicated Draft 7 uniqueItems behavior that landed in feat(generator): add AckInfer and AckModel generation #133.
  • Document numeric normalization and anyOf branch ordering, and add a focused Chrome regression gate.

Context

The VM preserves an int/double representation boundary that JavaScript does not. Strict runtime-type checks therefore made mathematically equivalent JSON numbers validate differently across platforms. JSON Schema defines integers by value, so this change normalizes numeric values only when conversion is lossless.

#133 independently fixed Draft 7 uniqueItems equality. This branch now incorporates current main and preserves that implementation instead of replacing it.

Behavior changes

  • Ack.integer() accepts finite numbers with no fractional part and returns an int when conversion is lossless.
  • Ack.double() accepts exactly representable numeric inputs and returns a double.
  • Integral inputs can match both schemas in Ack.anyOf; the first successful branch determines the runtime representation.
  • Ack.number() continues to preserve the input's numeric representation.
  • Ack.integer().safe() rejects values outside JavaScript's portable integer range without overflowing on the native minimum integer.

No public API signatures or generated JSON Schema shapes change.

Verification

  • fvm dart run melos run ci --no-select — passed (strict analysis; root, Dart, and Flutter tests)
  • Focused numeric, collection, and uniqueItems tests on Chrome — passed; one native-only precision case skipped as intended on JavaScript
  • fvm dart scripts/api_check.dart ack 1.1.0 — passed
  • git diff --check origin/main...HEAD — passed

@leoafarias
leoafarias marked this pull request as ready for review September 1, 2026 22:44
@leoafarias
leoafarias merged commit f96eedb into main Sep 1, 2026
8 checks passed
@leoafarias
leoafarias deleted the codex/fix-numeric-platform-parity branch September 1, 2026 22:44
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.

2 participants