Skip to content

Version 1.3.36 - #1704

Merged
sinclairzx81 merged 3 commits into
mainfrom
record
Oct 6, 2026
Merged

sinclairzx81 merged 3 commits into
mainfrom
record

Conversation

@sinclairzx81

Copy link
Copy Markdown
Owner

This PR corrects an issue with UnionPrioritySort(...) where user-defined string patterns were being remapped to ^.*$ (TString). This happened because the Type.RecordKey(...) API is unable to decode user-defined regular expressions as a TTemplateLiteral, and so falls back to TString. This PR instead uses the Type.RecordPattern(...) API within the Value.UnionPrioritySort(...) module to ensure the user-defined pattern is retained for Record keys.

Fixes: #1703


Tests

The following (Test 26) is resolved in 1.3.36.

Test('Should Clean 25', () => {
  Settings.Set({ unionPrioritySort: false })
  const T = Type.Record(Type.String({ pattern: '^custom[A-Z]' }), Type.Any())
  const A = Value.Clean(T, { customColor: 'Red', rating: 5 })
  Assert.IsEqual(A, { customColor: 'Red' })
  Settings.Reset()
})
Test('Should Clean 26', () => {
  Settings.Set({ unionPrioritySort: true })
  const T = Type.Record(Type.String({ pattern: '^custom[A-Z]' }), Type.Any())
  const A = Value.Clean(T, { customColor: 'Red', rating: 5 })
  Assert.IsEqual(A, { customColor: 'Red' }) // fixed in 1.3.36
  Settings.Reset()
})

@sinclairzx81
sinclairzx81 merged commit b180922 into main Oct 6, 2026
6 checks passed
@sinclairzx81
sinclairzx81 deleted the record branch October 12, 2026 15:41
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.

Regression since 1.3.0: Value.Clean keeps every key of a Record whose key is a regex-constrained String

1 participant