@sinclair/typebox 0.24.25 → 0.24.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -71,16 +71,7 @@ var Property;
71
71
  function Alpha(code) {
72
72
  return (code >= 65 && code <= 90) || (code >= 97 && code <= 122);
73
73
  }
74
- function AssertEscapeCharacters(propertyName) {
75
- for (let i = 0; i < propertyName.length; i++) {
76
- const code = propertyName.charCodeAt(i);
77
- if ((code >= 7 && code <= 13) || code === 27 || code === 127) {
78
- throw Error('Property: Invalid escape character found in property key');
79
- }
80
- }
81
- }
82
74
  function Check(propertyName) {
83
- AssertEscapeCharacters(propertyName);
84
75
  if (propertyName.length === 0)
85
76
  return false;
86
77
  {
@@ -132,7 +123,7 @@ var TypeCompiler;
132
123
  yield `(typeof ${value} === 'boolean')`;
133
124
  }
134
125
  function* Constructor(schema, value) {
135
- yield* Visit(schema.returns, value);
126
+ yield* Visit(schema.returns, `${value}.prototype`);
136
127
  }
137
128
  function* Function(schema, value) {
138
129
  yield `(typeof ${value} === 'function')`;
package/errors/errors.js CHANGED
@@ -110,7 +110,7 @@ var ValueErrors;
110
110
  }
111
111
  }
112
112
  function* Constructor(schema, references, path, value) {
113
- yield* Visit(schema.returns, references, path, value);
113
+ yield* Visit(schema.returns, references, path, value.prototype);
114
114
  }
115
115
  function* Function(schema, references, path, value) {
116
116
  if (!(typeof value === 'function')) {
package/guard/guard.js CHANGED
@@ -47,6 +47,17 @@ var TypeGuard;
47
47
  return false;
48
48
  }
49
49
  }
50
+ function IsValidPropertyKey(value) {
51
+ if (typeof value !== 'string')
52
+ return false;
53
+ for (let i = 0; i < value.length; i++) {
54
+ const code = value.charCodeAt(i);
55
+ if ((code >= 7 && code <= 13) || code === 27 || code === 127) {
56
+ return false;
57
+ }
58
+ }
59
+ return true;
60
+ }
50
61
  function IsString(value) {
51
62
  return typeof value === 'string';
52
63
  }
@@ -66,7 +77,7 @@ var TypeGuard;
66
77
  return value === undefined || (value !== undefined && IsString(value));
67
78
  }
68
79
  function IsOptionalPattern(value) {
69
- return value === undefined || (value !== undefined && IsPattern(value));
80
+ return value === undefined || (value !== undefined && IsString(value) && IsPattern(value));
70
81
  }
71
82
  /** Returns true if the given schema is TAny */
72
83
  function TAny(schema) {
@@ -75,7 +86,7 @@ var TypeGuard;
75
86
  TypeGuard.TAny = TAny;
76
87
  /** Returns true if the given schema is TArray */
77
88
  function TArray(schema) {
78
- return IsObject(schema) && schema[Types.Kind] === 'Array' && schema.type === 'array' && TSchema(schema.items) && IsOptionalNumber(schema.minItems) && IsOptionalNumber(schema.maxItems);
89
+ return IsObject(schema) && schema[Types.Kind] === 'Array' && schema.type === 'array' && TSchema(schema.items) && IsOptionalNumber(schema.minItems) && IsOptionalNumber(schema.maxItems) && IsOptionalBoolean(schema.uniqueItems);
79
90
  }
80
91
  TypeGuard.TArray = TArray;
81
92
  /** Returns true if the given schema is TBoolean */
@@ -152,8 +163,10 @@ var TypeGuard;
152
163
  IsOptionalNumber(schema.maxProperties))) {
153
164
  return false;
154
165
  }
155
- for (const property of Object.values(schema.properties)) {
156
- if (!TSchema(property))
166
+ for (const [key, value] of Object.entries(schema.properties)) {
167
+ if (!IsValidPropertyKey(key))
168
+ return false;
169
+ if (!TSchema(value))
157
170
  return false;
158
171
  }
159
172
  return true;
@@ -166,7 +179,7 @@ var TypeGuard;
166
179
  TypeGuard.TPromise = TPromise;
167
180
  /** Returns true if the given schema is TRecord */
168
181
  function TRecord(schema) {
169
- if (!(IsObject(schema) && schema[Types.Kind] === 'Record' && schema.type === 'object' && IsObject(schema.patternProperties))) {
182
+ if (!(IsObject(schema) && schema[Types.Kind] === 'Record' && schema.type === 'object' && schema.additionalProperties === false && IsObject(schema.patternProperties))) {
170
183
  return false;
171
184
  }
172
185
  const keys = Object.keys(schema.patternProperties);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinclair/typebox",
3
- "version": "0.24.25",
3
+ "version": "0.24.26",
4
4
  "description": "JSONSchema Type Builder with Static Type Resolution for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",
package/value/check.js CHANGED
@@ -60,7 +60,7 @@ var ValueCheck;
60
60
  return typeof value === 'boolean';
61
61
  }
62
62
  function Constructor(schema, references, value) {
63
- return Visit(schema.returns, references, value);
63
+ return Visit(schema.returns, references, value.prototype);
64
64
  }
65
65
  function Function(schema, references, value) {
66
66
  return typeof value === 'function';