Skip to content

fix(model): count Unicode code points when validating string length - #53

Merged
heoblitz merged 2 commits into
toss:mainfrom
hyxx-su:fix/schema-unicode-length
Nov 24, 2026
Merged

heoblitz merged 2 commits into
toss:mainfrom
hyxx-su:fix/schema-unicode-length

Conversation

@hyxx-su

@hyxx-su hyxx-su commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Summary

The same plugin payload can pass string length validation on the Mac and fail on Android. For example, 🇰🇷 is one Swift Character made up of two Unicode code points. Swift accepted it with maxLength: 1 and rejected it with minLength: 2. Android gave the opposite result for both.

Count Unicode scalars when checking either bound in Swift. This matches the JSON Schema string data model and Android's existing code point count. Strings without a length constraint skip the count.

Changelog

Swift now applies plugin schema string length limits in Unicode code points, matching Android for flag emoji and combining marks.

Test Plan

  • On main, swift test --filter validatesStringLengthInUnicodeCodePoints with the new regression test reported four failed assertions across the flag and decomposed accent cases.
  • After the fix, DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer script/test swift passed all 489 tests (202 root package, 285 Mac package, 2 SDK consumer).
  • Compiled the Swift and Kotlin validators and compared their results for A, 😀, 🇰🇷 and e\u0301 against minLength: 2 and maxLength: 1. All eight results matched. The Kotlin validator ran on the JVM. The full Android build and device/USB tests were not run locally.

@heoblitz
heoblitz merged commit ed966e6 into toss:main Nov 24, 2026
7 checks passed
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