Skip to content

Commit 60d1d51

Browse files
authored
Version 1.1.15 (#1560)
* Specification Unicode * ChangeLog * Version
1 parent 83ecb94 commit 60d1d51

41 files changed

Lines changed: 333 additions & 649 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

changelog/1.1.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
---
44

55
### Version Updates
6+
- [Revision 1.1.15](https://github.com/sinclairzx81/typebox/pull/1560)
7+
- Unicode Support for Pattern and PatternProperties
68
- [Revision 1.1.14](https://github.com/sinclairzx81/typebox/pull/1558)
79
- Additional Extends Match Pattern Usage
810
- Documentation

design/website/docs/schema/6_specification.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ These keywords form the core of TypeBox's compliance target. A ✅ indicates ful
4343
| multipleOf | - |||||||
4444
| not | - |||||||
4545
| oneOf | - |||||||
46-
| pattern |||||| 10/12 | 10/12 |
47-
| patternProperties ||||||| 25/26 |
46+
| pattern |||||| | |
47+
| patternProperties ||||||| |
4848
| prefixItems | - | - | - | - | - |||
4949
| properties ||||||||
5050
| propertyNames | - | - ||||||
@@ -68,7 +68,7 @@ Optional test suites cover supplementary keywords, format validators, and propos
6868
| cross-draft | - | - | - | 1/2 | 1/3 | 0/1 | - |
6969
| dependencies-compatibility | - | - | - | - ||||
7070
| dynamicRef | - | - | - | - | - | 1/2 | 1/2 |
71-
| ecmascript-regex | - | 64/74 | 64/74 | 64/74 | 64/74 | 64/74 | 64/74 |
71+
| ecmascript-regex | - | 69/74 | 69/74 | 69/74 | 69/74 | 69/74 | 69/74 |
7272
| float-overflow | - |||||||
7373
| format-annotation | - | - | - | - | - | - | 114/133 |
7474
| format-assertion | - | - | - | - | - || - |
@@ -98,7 +98,7 @@ Optional test suites cover supplementary keywords, format validators, and propos
9898
| format/uuid | - | - | - | - ||||
9999
| id | - | 2/3 | 6/7 | 6/7 | 2/3 | 2/3 | 2/3 |
100100
| no-schema | - | - | - | - ||| - |
101-
| non-bmp-regex | 9/12 | 9/12 | 9/12 | 9/12 | 9/12 | 9/12 | 9/12 |
101+
| non-bmp-regex | | | | | | | |
102102
| proposals/propertyDependencies/additionalProperties | - | - | - | - | - | - ||
103103
| proposals/propertyDependencies/dynamicRef | - | - | - | - | - | - | 4/8 |
104104
| proposals/propertyDependencies/propertyDependencies | - | - | - | - | - | - | 17/21 |

docs/docs/schema/6_specification.html

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ <h2>Required Keywords</h2>
355355
<td align="left"></td>
356356
<td align="left"></td>
357357
<td align="left"></td>
358-
<td align="left">10/12</td>
359-
<td align="left">10/12</td>
358+
<td align="left"></td>
359+
<td align="left"></td>
360360
</tr>
361361
<tr>
362362
<td align="left">patternProperties</td>
@@ -366,7 +366,7 @@ <h2>Required Keywords</h2>
366366
<td align="left"></td>
367367
<td align="left"></td>
368368
<td align="left"></td>
369-
<td align="left">25/26</td>
369+
<td align="left"></td>
370370
</tr>
371371
<tr>
372372
<td align="left">prefixItems</td>
@@ -547,12 +547,12 @@ <h2>Optional Keywords and Proposals</h2>
547547
<tr>
548548
<td align="left">ecmascript-regex</td>
549549
<td align="left">-</td>
550-
<td align="left">64/74</td>
551-
<td align="left">64/74</td>
552-
<td align="left">64/74</td>
553-
<td align="left">64/74</td>
554-
<td align="left">64/74</td>
555-
<td align="left">64/74</td>
550+
<td align="left">69/74</td>
551+
<td align="left">69/74</td>
552+
<td align="left">69/74</td>
553+
<td align="left">69/74</td>
554+
<td align="left">69/74</td>
555+
<td align="left">69/74</td>
556556
</tr>
557557
<tr>
558558
<td align="left">float-overflow</td>
@@ -846,13 +846,13 @@ <h2>Optional Keywords and Proposals</h2>
846846
</tr>
847847
<tr>
848848
<td align="left">non-bmp-regex</td>
849-
<td align="left">9/12</td>
850-
<td align="left">9/12</td>
851-
<td align="left">9/12</td>
852-
<td align="left">9/12</td>
853-
<td align="left">9/12</td>
854-
<td align="left">9/12</td>
855-
<td align="left">9/12</td>
849+
<td align="left"></td>
850+
<td align="left"></td>
851+
<td align="left"></td>
852+
<td align="left"></td>
853+
<td align="left"></td>
854+
<td align="left"></td>
855+
<td align="left"></td>
856856
</tr>
857857
<tr>
858858
<td align="left">proposals/propertyDependencies/additionalProperties</td>

src/schema/engine/pattern.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ import { Guard as G, EmitGuard as E } from '../../guard/index.ts'
3838
// Build
3939
// ------------------------------------------------------------------
4040
export function BuildPattern(stack: Stack, context: BuildContext, schema: Schema.XPattern, value: string): string {
41-
const regexp = Externals.CreateVariable(G.IsString(schema.pattern) ? new RegExp(schema.pattern) : schema.pattern)
41+
const regexp = Externals.CreateVariable(G.IsString(schema.pattern) ? new RegExp(schema.pattern, 'u') : schema.pattern)
4242
return E.Call(E.Member(regexp, 'test'), [value])
4343
}
4444
// ------------------------------------------------------------------
4545
// Check
4646
// ------------------------------------------------------------------
4747
export function CheckPattern(stack: Stack, context: CheckContext, schema: Schema.XPattern, value: string): boolean {
48-
const regexp = G.IsString(schema.pattern) ? new RegExp(schema.pattern) : schema.pattern
48+
const regexp = G.IsString(schema.pattern) ? new RegExp(schema.pattern, 'u') : schema.pattern
4949
return regexp.test(value)
5050
}
5151
// ------------------------------------------------------------------

src/schema/engine/patternProperties.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import { BuildSchema, CheckSchema, ErrorSchema } from './schema.ts'
4343
export function BuildPatternProperties(stack: Stack, context: BuildContext, schema: Schema.XPatternProperties, value: string): string {
4444
return E.ReduceAnd(G.Entries(schema.patternProperties).map(([pattern, schema]) => {
4545
const [key, prop] = [Unique(), Unique()]
46-
const regexp = Externals.CreateVariable(new RegExp(pattern))
46+
const regexp = Externals.CreateVariable(new RegExp(pattern, 'u'))
4747
const notKey = E.Not(E.Call(E.Member(regexp, 'test'), [key]))
4848
const isSchema = BuildSchema(stack, context, schema, prop)
4949
const addKey = context.AddKey(key)
@@ -56,7 +56,7 @@ export function BuildPatternProperties(stack: Stack, context: BuildContext, sche
5656
// ------------------------------------------------------------------
5757
export function CheckPatternProperties(stack: Stack, context: CheckContext, schema: Schema.XPatternProperties, value: Record<PropertyKey, unknown>): boolean {
5858
return G.Every(G.Entries(schema.patternProperties), 0, ([pattern, schema]) => {
59-
const regexp = new RegExp(pattern)
59+
const regexp = new RegExp(pattern, 'u')
6060
return G.Every(G.Entries(value), 0, ([key, prop]) => {
6161
return !regexp.test(key) || CheckSchema(stack, context, schema, prop) && context.AddKey(key)
6262
})
@@ -68,7 +68,7 @@ export function CheckPatternProperties(stack: Stack, context: CheckContext, sche
6868
export function ErrorPatternProperties(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XPatternProperties, value: Record<PropertyKey, unknown>): boolean {
6969
return G.EveryAll(G.Entries(schema.patternProperties), 0, ([pattern, schema]) => {
7070
const nextSchemaPath = `${schemaPath}/patternProperties/${pattern}`
71-
const regexp = new RegExp(pattern)
71+
const regexp = new RegExp(pattern, 'u')
7272
return G.EveryAll(G.Entries(value), 0, ([key, value]) => {
7373
const nextInstancePath = `${instancePath}/${key}`
7474
const notKey = !regexp.test(key)

task/spec/refresh.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,17 @@ function report(suite: JSONSchemaTestSuite): void {
6868
const requiredTable = Report.reportRequired(suite, {
6969
ignore: ['defs', 'definitions', 'divisibleBy', 'disallow', 'dynamicRef', 'extends', 'refRemote', 'vocabulary']
7070
})
71+
console.log('')
72+
console.log('## Required Keywords')
73+
console.log('')
74+
console.log(requiredTable)
75+
console.log('')
7176
const optionalTable = Report.reportOptional(suite, {
7277
ignore: []
7378
})
74-
console.log('--------------------------------------------------------')
75-
console.log('OPTIONAL')
76-
console.log('--------------------------------------------------------')
77-
console.log()
79+
console.log('## Optional Keywords and Proposals')
80+
console.log('')
7881
console.log(optionalTable)
79-
console.log('--------------------------------------------------------')
80-
console.log('REQUIRED')
81-
console.log('--------------------------------------------------------')
82-
console.log()
83-
console.log(requiredTable)
8482
}
8583
// ------------------------------------------------------------------
8684
// Write

tasks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Metrics } from './task/metrics/index.ts'
99
import { Spec } from './task/spec/index.ts'
1010
import { Task } from 'tasksmith'
1111

12-
const Version = '1.1.14'
12+
const Version = '1.1.15'
1313

1414
// ------------------------------------------------------------------
1515
// Build

test/jsonschema/cases/draft2019-09/optional/_ecmascript-regex.json

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,4 @@
11
[
2-
{
3-
"description": "patterns always use unicode semantics with pattern",
4-
"schema": {
5-
"$schema": "https://json-schema.org/draft/2019-09/schema",
6-
"pattern": "\\p{Letter}cole"
7-
},
8-
"tests": [
9-
{
10-
"description": "ascii character in json string",
11-
"data": "Les hivers de mon enfance etaient des saisons longues, longues. Nous vivions en trois lieux: l'ecole, l'eglise et la patinoire; mais la vraie vie etait sur la patinoire.",
12-
"valid": true
13-
},
14-
{
15-
"description": "literal unicode character in json string",
16-
"data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'école, l'église et la patinoire; mais la vraie vie était sur la patinoire.",
17-
"valid": true
18-
},
19-
{
20-
"description": "unicode character in hex format in string",
21-
"data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'école, l'église et la patinoire; mais la vraie vie était sur la patinoire.",
22-
"valid": true
23-
}
24-
]
25-
},
26-
{
27-
"description": "pattern with non-ASCII digits",
28-
"schema": {
29-
"$schema": "https://json-schema.org/draft/2019-09/schema",
30-
"pattern": "^\\p{digit}+$"
31-
},
32-
"tests": [
33-
{
34-
"description": "ascii digits",
35-
"data": "42",
36-
"valid": true
37-
},
38-
{
39-
"description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)",
40-
"data": "৪২",
41-
"valid": true
42-
}
43-
]
44-
},
452
{
463
"description": "patterns always use unicode semantics with patternProperties",
474
"schema": {

test/jsonschema/cases/draft2019-09/optional/_non-bmp-regex.json

Lines changed: 0 additions & 43 deletions
This file was deleted.

test/jsonschema/cases/draft2019-09/optional/ecmascript-regex.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,21 @@
306306
"pattern": "\\p{Letter}cole"
307307
},
308308
"tests": [
309+
{
310+
"description": "ascii character in json string",
311+
"data": "Les hivers de mon enfance etaient des saisons longues, longues. Nous vivions en trois lieux: l'ecole, l'eglise et la patinoire; mais la vraie vie etait sur la patinoire.",
312+
"valid": true
313+
},
314+
{
315+
"description": "literal unicode character in json string",
316+
"data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'école, l'église et la patinoire; mais la vraie vie était sur la patinoire.",
317+
"valid": true
318+
},
319+
{
320+
"description": "unicode character in hex format in string",
321+
"data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'école, l'église et la patinoire; mais la vraie vie était sur la patinoire.",
322+
"valid": true
323+
},
309324
{
310325
"description": "unicode matching is case-sensitive",
311326
"data": "LES HIVERS DE MON ENFANCE ÉTAIENT DES SAISONS LONGUES, LONGUES. NOUS VIVIONS EN TROIS LIEUX: L'ÉCOLE, L'ÉGLISE ET LA PATINOIRE; MAIS LA VRAIE VIE ÉTAIT SUR LA PATINOIRE.",
@@ -397,10 +412,20 @@
397412
"pattern": "^\\p{digit}+$"
398413
},
399414
"tests": [
415+
{
416+
"description": "ascii digits",
417+
"data": "42",
418+
"valid": true
419+
},
400420
{
401421
"description": "ascii non-digits",
402422
"data": "-%#",
403423
"valid": false
424+
},
425+
{
426+
"description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)",
427+
"data": "৪২",
428+
"valid": true
404429
}
405430
]
406431
},

0 commit comments

Comments
 (0)