@sinclair/typebox 0.25.12 → 0.25.14

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.
@@ -108,7 +108,7 @@ exports.TypeCompilerUnknownTypeError = TypeCompilerUnknownTypeError;
108
108
  var TypeCompiler;
109
109
  (function (TypeCompiler) {
110
110
  function IsNumber(value) {
111
- return typeof value === 'number';
111
+ return typeof value === 'number' && !globalThis.isNaN(value);
112
112
  }
113
113
  // -------------------------------------------------------------------
114
114
  // Types
@@ -174,7 +174,7 @@ var TypeCompiler;
174
174
  yield `(${value} === null)`;
175
175
  }
176
176
  function* Number(schema, value) {
177
- yield `(typeof ${value} === 'number')`;
177
+ yield `(typeof ${value} === 'number' && !isNaN(${value}))`;
178
178
  if (IsNumber(schema.multipleOf))
179
179
  yield `(${value} % ${schema.multipleOf} === 0)`;
180
180
  if (IsNumber(schema.exclusiveMinimum))
package/errors/errors.js CHANGED
@@ -101,7 +101,7 @@ exports.ValueErrorsUnknownTypeError = ValueErrorsUnknownTypeError;
101
101
  var ValueErrors;
102
102
  (function (ValueErrors) {
103
103
  function IsNumber(value) {
104
- return typeof value === 'number';
104
+ return typeof value === 'number' && !isNaN(value);
105
105
  }
106
106
  function* Any(schema, references, path, value) { }
107
107
  function* Array(schema, references, path, value) {
@@ -161,7 +161,7 @@ var ValueErrors;
161
161
  }
162
162
  }
163
163
  function* Integer(schema, references, path, value) {
164
- if (!(typeof value === 'number')) {
164
+ if (!(typeof value === 'number' && globalThis.Number.isInteger(value))) {
165
165
  return yield { type: ValueErrorType.Number, schema, path, value, message: `Expected number` };
166
166
  }
167
167
  if (!globalThis.Number.isInteger(value)) {
@@ -198,7 +198,7 @@ var ValueErrors;
198
198
  }
199
199
  }
200
200
  function* Number(schema, references, path, value) {
201
- if (!(typeof value === 'number')) {
201
+ if (!(typeof value === 'number' && !isNaN(value))) {
202
202
  return yield { type: ValueErrorType.Number, schema, path, value, message: `Expected number` };
203
203
  }
204
204
  if (IsNumber(schema.multipleOf) && !(value % schema.multipleOf === 0)) {
package/guard/guard.js CHANGED
@@ -70,7 +70,7 @@ var TypeGuard;
70
70
  return typeof value === 'string';
71
71
  }
72
72
  function IsNumber(value) {
73
- return typeof value === 'number';
73
+ return typeof value === 'number' && !isNaN(value);
74
74
  }
75
75
  function IsBoolean(value) {
76
76
  return typeof value === 'boolean';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinclair/typebox",
3
- "version": "0.25.12",
3
+ "version": "0.25.14",
4
4
  "description": "JSONSchema Type Builder with Static Type Resolution for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",
package/readme.md CHANGED
@@ -73,8 +73,8 @@ License MIT
73
73
  - [Overview](#overview)
74
74
  - [Example](#Example)
75
75
  - [Types](#types)
76
- - [Standard Types](#types-standard)
77
- - [Extended Types](#types-extended)
76
+ - [Standard](#types-standard)
77
+ - [Extended](#types-extended)
78
78
  - [Modifiers](#types-modifiers)
79
79
  - [Options](#types-options)
80
80
  - [Reference](#types-reference)
@@ -189,7 +189,7 @@ TypeBox provides a set of functions that allow you to compose JSON Schema simila
189
189
 
190
190
  <a name='types-standard'></a>
191
191
 
192
- ### Standard Types
192
+ ### Standard
193
193
 
194
194
  The following table lists the Standard TypeBox types.
195
195
 
@@ -396,7 +396,7 @@ The following table lists the Standard TypeBox types.
396
396
 
397
397
  <a name='types-extended'></a>
398
398
 
399
- ### Extended Types
399
+ ### Extended
400
400
 
401
401
  TypeBox provides a set of extended types that can be used to express schematics for core JavaScript constructs and primitives. Extended types are not valid JSON Schema and will not validate using typical validation. These types however can be used to frame JSON schema and describe callable RPC interfaces that may receive JSON validated data.
402
402
 
@@ -1143,27 +1143,28 @@ The custom module is an optional import.
1143
1143
  import { Custom } from '@sinclair/typebox/custom'
1144
1144
  ```
1145
1145
 
1146
- The following creates a `BigInt` type.
1146
+ The following creates a `bigint` type.
1147
1147
 
1148
1148
  ```typescript
1149
1149
  import { Type, Kind } from '@sinclair/typebox'
1150
1150
 
1151
- Custom.Set('BigInt', (schema, value) => typeof value === 'bigint')
1151
+ Custom.Set('bigint', (schema, value) => typeof value === 'bigint')
1152
+ // ▲
1152
1153
  // │
1153
- // └────────────────────────────┐ The [Kind] is used to match registered type
1154
+ // └────────────────────────────┐
1154
1155
  // │
1155
- const T = Type.Unsafe<bigint>({ [Kind]: 'BigInt' }) // const T = { [Kind]: 'BigInt' }
1156
+ const T = Type.Unsafe<bigint>({ [Kind]: 'bigint' }) // const T = { [Kind]: 'BigInt' }
1156
1157
 
1157
- const A = TypeCompiler.Compile(T).Check(65536) // const A = false
1158
+ const A = TypeCompiler.Compile(T).Check(1n) // const A = true
1158
1159
 
1159
- const B = Value.Check(T, 65536n) // const B = true
1160
+ const B = Value.Check(T, 1) // const B = false
1160
1161
  ```
1161
1162
 
1162
1163
  <a name='typecheck-custom-formats'></a>
1163
1164
 
1164
1165
  ### Custom Formats
1165
1166
 
1166
- Use the format module to create user defined string formats. If using Ajv, please refer to the official Ajv format documentation located [here](https://ajv.js.org/guide/formats.html). The format module is specific to TypeBox can only be used with the TypeCompiler and Value modules.
1167
+ Use the format module to create user defined string formats. The format module is specific to TypeBox can only be used with the TypeCompiler and Value modules. If using Ajv, please refer to the official Ajv format documentation located [here](https://ajv.js.org/guide/formats.html).
1167
1168
 
1168
1169
  The format module is an optional import.
1169
1170
 
@@ -1171,20 +1172,19 @@ The format module is an optional import.
1171
1172
  import { Format } from '@sinclair/typebox/format'
1172
1173
  ```
1173
1174
 
1174
- The following creates a palindrome string format.
1175
+ The following creates a custom string format that checks for lowercase.
1175
1176
 
1176
1177
  ```typescript
1177
- Format.Set('palindrome', value => value === value.split('').reverse().join(''))
1178
- ```
1179
-
1180
- Once set, this format can then be used by the TypeCompiler and Value modules.
1181
-
1182
- ```typescript
1183
- const T = Type.String({ format: 'palindrome' })
1178
+ Format.Set('lowercase', value => value === value.toLowerCase())
1179
+ // ▲
1180
+ // │
1181
+ // └────────────────────┐
1182
+ // │
1183
+ const T = Type.String({ format: 'lowercase' })
1184
1184
 
1185
- const A = TypeCompiler.Compile(T).Check('engine') // const A = false
1185
+ const A = TypeCompiler.Compile(T).Check('action') // const A = true
1186
1186
 
1187
- const B = Value.Check(T, 'kayak') // const B = true
1187
+ const B = Value.Check(T, 'Action') // const B = false
1188
1188
  ```
1189
1189
 
1190
1190
  <a name='benchmark'></a>
@@ -1205,29 +1205,29 @@ This benchmark measures compilation performance for varying types. You can revie
1205
1205
  ┌──────────────────┬────────────┬──────────────┬──────────────┬──────────────┐
1206
1206
  │ (index) │ Iterations │ Ajv │ TypeCompiler │ Performance │
1207
1207
  ├──────────────────┼────────────┼──────────────┼──────────────┼──────────────┤
1208
- │ Number │ 2000 │ ' 415 ms' │ ' 14 ms' │ ' 29.64 x' │
1209
- │ String │ 2000 │ ' 335 ms' │ ' 12 ms' │ ' 27.92 x' │
1210
- │ Boolean │ 2000 │ ' 295 ms' │ ' 13 ms' │ ' 22.69 x' │
1211
- │ Null │ 2000 │ ' 255 ms' │ ' 8 ms' │ ' 31.88 x' │
1212
- │ RegEx │ 2000 │ ' 482 ms' │ ' 17 ms' │ ' 28.35 x' │
1213
- │ ObjectA │ 2000 │ ' 2700 ms' │ ' 55 ms' │ ' 49.09 x' │
1214
- │ ObjectB │ 2000 │ ' 2871 ms' │ ' 36 ms' │ ' 79.75 x' │
1215
- │ Tuple │ 2000 │ ' 1229 ms' │ ' 22 ms' │ ' 55.86 x' │
1216
- │ Union │ 2000 │ ' 1216 ms' │ ' 26 ms' │ ' 46.77 x' │
1217
- │ Vector4 │ 2000 │ ' 1575 ms' │ ' 25 ms' │ ' 63.00 x' │
1218
- │ Matrix4 │ 2000 │ ' 908 ms' │ ' 13 ms' │ ' 69.85 x' │
1219
- │ Literal_String │ 2000 │ ' 353 ms' │ ' 9 ms' │ ' 39.22 x' │
1220
- │ Literal_Number │ 2000 │ ' 371 ms' │ ' 7 ms' │ ' 53.00 x' │
1221
- │ Literal_Boolean │ 2000 │ ' 361 ms' │ ' 8 ms' │ ' 45.13 x' │
1222
- │ Array_Number │ 2000 │ ' 694 ms' │ ' 7 ms' │ ' 99.14 x' │
1223
- │ Array_String │ 2000 │ ' 778 ms' │ ' 8 ms' │ ' 97.25 x' │
1224
- │ Array_Boolean │ 2000 │ ' 735 ms' │ ' 7 ms' │ ' 105.00 x' │
1225
- │ Array_ObjectA │ 2000 │ ' 3732 ms' │ ' 44 ms' │ ' 84.82 x' │
1226
- │ Array_ObjectB │ 2000 │ ' 3624 ms' │ ' 40 ms' │ ' 90.60 x' │
1227
- │ Array_Tuple │ 2000 │ ' 2101 ms' │ ' 15 ms' │ ' 140.07 x' │
1228
- │ Array_Union │ 2000 │ ' 1480 ms' │ ' 25 ms' │ ' 59.20 x' │
1229
- │ Array_Vector4 │ 2000 │ ' 2175 ms' │ ' 18 ms' │ ' 120.83 x' │
1230
- │ Array_Matrix4 │ 2000 │ ' 1516 ms' │ ' 13 ms' │ ' 116.62 x' │
1208
+ │ Number │ 2000 │ ' 437 ms' │ ' 15 ms' │ ' 29.13 x' │
1209
+ │ String │ 2000 │ ' 332 ms' │ ' 13 ms' │ ' 25.54 x' │
1210
+ │ Boolean │ 2000 │ ' 293 ms' │ ' 12 ms' │ ' 24.42 x' │
1211
+ │ Null │ 2000 │ ' 259 ms' │ ' 9 ms' │ ' 28.78 x' │
1212
+ │ RegEx │ 2000 │ ' 505 ms' │ ' 21 ms' │ ' 24.05 x' │
1213
+ │ ObjectA │ 2000 │ ' 2726 ms' │ ' 53 ms' │ ' 51.43 x' │
1214
+ │ ObjectB │ 2000 │ ' 2835 ms' │ ' 37 ms' │ ' 76.62 x' │
1215
+ │ Tuple │ 2000 │ ' 1239 ms' │ ' 24 ms' │ ' 51.63 x' │
1216
+ │ Union │ 2000 │ ' 1244 ms' │ ' 34 ms' │ ' 36.59 x' │
1217
+ │ Vector4 │ 2000 │ ' 1521 ms' │ ' 21 ms' │ ' 72.43 x' │
1218
+ │ Matrix4 │ 2000 │ ' 836 ms' │ ' 10 ms' │ ' 83.60 x' │
1219
+ │ Literal_String │ 2000 │ ' 333 ms' │ ' 9 ms' │ ' 37.00 x' │
1220
+ │ Literal_Number │ 2000 │ ' 357 ms' │ ' 9 ms' │ ' 39.67 x' │
1221
+ │ Literal_Boolean │ 2000 │ ' 352 ms' │ ' 6 ms' │ ' 58.67 x' │
1222
+ │ Array_Number │ 2000 │ ' 685 ms' │ ' 12 ms' │ ' 57.08 x' │
1223
+ │ Array_String │ 2000 │ ' 720 ms' │ ' 12 ms' │ ' 60.00 x' │
1224
+ │ Array_Boolean │ 2000 │ ' 709 ms' │ ' 8 ms' │ ' 88.63 x' │
1225
+ │ Array_ObjectA │ 2000 │ ' 3590 ms' │ ' 40 ms' │ ' 89.75 x' │
1226
+ │ Array_ObjectB │ 2000 │ ' 3610 ms' │ ' 51 ms' │ ' 70.78 x' │
1227
+ │ Array_Tuple │ 2000 │ ' 2124 ms' │ ' 19 ms' │ ' 111.79 x' │
1228
+ │ Array_Union │ 2000 │ ' 1533 ms' │ ' 21 ms' │ ' 73.00 x' │
1229
+ │ Array_Vector4 │ 2000 │ ' 2278 ms' │ ' 19 ms' │ ' 119.89 x' │
1230
+ │ Array_Matrix4 │ 2000 │ ' 1504 ms' │ ' 20 ms' │ ' 75.20 x' │
1231
1231
  └──────────────────┴────────────┴──────────────┴──────────────┴──────────────┘
1232
1232
  ```
1233
1233
 
@@ -1241,31 +1241,31 @@ This benchmark measures validation performance for varying types. You can review
1241
1241
  ┌──────────────────┬────────────┬──────────────┬──────────────┬──────────────┬──────────────┐
1242
1242
  │ (index) │ Iterations │ ValueCheck │ Ajv │ TypeCompiler │ Performance │
1243
1243
  ├──────────────────┼────────────┼──────────────┼──────────────┼──────────────┼──────────────┤
1244
- │ Number │ 1000000 │ ' 28 ms' │ ' 6 ms' │ ' 5 ms' │ ' 1.20 x' │
1245
- │ String │ 1000000 │ ' 22 ms' │ ' 21 ms' │ ' 13 ms' │ ' 1.62 x' │
1246
- │ Boolean │ 1000000 │ ' 22 ms' │ ' 21 ms' │ ' 11 ms' │ ' 1.91 x' │
1247
- │ Null │ 1000000 │ ' 25 ms' │ ' 20 ms' │ ' 11 ms' │ ' 1.82 x' │
1248
- │ RegEx │ 1000000 │ ' 167 ms' │ ' 48 ms' │ ' 38 ms' │ ' 1.26 x' │
1249
- │ ObjectA │ 1000000 │ ' 591 ms' │ ' 36 ms' │ ' 22 ms' │ ' 1.64 x' │
1250
- │ ObjectB │ 1000000 │ ' 1168 ms' │ ' 61 ms' │ ' 37 ms' │ ' 1.65 x' │
1251
- │ Tuple │ 1000000 │ ' 127 ms' │ ' 24 ms' │ ' 14 ms' │ ' 1.71 x' │
1252
- │ Union │ 1000000 │ ' 340 ms' │ ' 26 ms' │ ' 16 ms' │ ' 1.63 x' │
1253
- │ Recursive │ 1000000 │ ' 3174 ms' │ ' 432 ms' │ ' 100 ms' │ ' 4.32 x' │
1254
- │ Vector4 │ 1000000 │ ' 142 ms' │ ' 24 ms' │ ' 12 ms' │ ' 2.00 x' │
1255
- │ Matrix4 │ 1000000 │ ' 577 ms' │ ' 40 ms' │ ' 28 ms' │ ' 1.43 x' │
1256
- │ Literal_String │ 1000000 │ ' 47 ms' │ ' 19 ms' │ ' 10 ms' │ ' 1.90 x' │
1257
- │ Literal_Number │ 1000000 │ ' 47 ms' │ ' 19 ms' │ ' 9 ms' │ ' 2.11 x' │
1258
- │ Literal_Boolean │ 1000000 │ ' 45 ms' │ ' 19 ms' │ ' 11 ms' │ ' 1.73 x' │
1259
- │ Array_Number │ 1000000 │ ' 432 ms' │ ' 33 ms' │ ' 19 ms' │ ' 1.74 x' │
1260
- │ Array_String │ 1000000 │ ' 462 ms' │ ' 32 ms' │ ' 22 ms' │ ' 1.45 x' │
1261
- │ Array_Boolean │ 1000000 │ ' 455 ms' │ ' 32 ms' │ ' 26 ms' │ ' 1.23 x' │
1262
- │ Array_ObjectA │ 1000000 │ ' 14595 ms' │ ' 2306 ms' │ ' 1496 ms' │ ' 1.54 x' │
1263
- │ Array_ObjectB │ 1000000 │ ' 17310 ms' │ ' 2625 ms' │ ' 2105 ms' │ ' 1.25 x' │
1264
- │ Array_Tuple │ 1000000 │ ' 1794 ms' │ ' 97 ms' │ ' 66 ms' │ ' 1.47 x' │
1265
- │ Array_Union │ 1000000 │ ' 5085 ms' │ ' 246 ms' │ ' 91 ms' │ ' 2.70 x' │
1266
- │ Array_Recursive │ 1000000 │ ' 59747 ms' │ ' 7866 ms' │ ' 1136 ms' │ ' 6.92 x' │
1267
- │ Array_Vector4 │ 1000000 │ ' 2375 ms' │ ' 99 ms' │ ' 48 ms' │ ' 2.06 x' │
1268
- │ Array_Matrix4 │ 1000000 │ ' 13115 ms' │ ' 385 ms' │ ' 246 ms' │ ' 1.57 x' │
1244
+ │ Number │ 1000000 │ ' 29 ms' │ ' 6 ms' │ ' 6 ms' │ ' 1.00 x' │
1245
+ │ String │ 1000000 │ ' 24 ms' │ ' 19 ms' │ ' 11 ms' │ ' 1.73 x' │
1246
+ │ Boolean │ 1000000 │ ' 22 ms' │ ' 20 ms' │ ' 11 ms' │ ' 1.82 x' │
1247
+ │ Null │ 1000000 │ ' 27 ms' │ ' 23 ms' │ ' 11 ms' │ ' 2.09 x' │
1248
+ │ RegEx │ 1000000 │ ' 160 ms' │ ' 52 ms' │ ' 40 ms' │ ' 1.30 x' │
1249
+ │ ObjectA │ 1000000 │ ' 577 ms' │ ' 37 ms' │ ' 26 ms' │ ' 1.42 x' │
1250
+ │ ObjectB │ 1000000 │ ' 990 ms' │ ' 50 ms' │ ' 37 ms' │ ' 1.35 x' │
1251
+ │ Tuple │ 1000000 │ ' 124 ms' │ ' 22 ms' │ ' 17 ms' │ ' 1.29 x' │
1252
+ │ Union │ 1000000 │ ' 318 ms' │ ' 24 ms' │ ' 16 ms' │ ' 1.50 x' │
1253
+ │ Recursive │ 1000000 │ ' 3102 ms' │ ' 408 ms' │ ' 102 ms' │ ' 4.00 x' │
1254
+ │ Vector4 │ 1000000 │ ' 150 ms' │ ' 23 ms' │ ' 13 ms' │ ' 1.77 x' │
1255
+ │ Matrix4 │ 1000000 │ ' 579 ms' │ ' 43 ms' │ ' 27 ms' │ ' 1.59 x' │
1256
+ │ Literal_String │ 1000000 │ ' 50 ms' │ ' 22 ms' │ ' 10 ms' │ ' 2.20 x' │
1257
+ │ Literal_Number │ 1000000 │ ' 47 ms' │ ' 21 ms' │ ' 11 ms' │ ' 1.91 x' │
1258
+ │ Literal_Boolean │ 1000000 │ ' 48 ms' │ ' 20 ms' │ ' 10 ms' │ ' 2.00 x' │
1259
+ │ Array_Number │ 1000000 │ ' 429 ms' │ ' 32 ms' │ ' 20 ms' │ ' 1.60 x' │
1260
+ │ Array_String │ 1000000 │ ' 474 ms' │ ' 33 ms' │ ' 25 ms' │ ' 1.32 x' │
1261
+ │ Array_Boolean │ 1000000 │ ' 447 ms' │ ' 35 ms' │ ' 31 ms' │ ' 1.13 x' │
1262
+ │ Array_ObjectA │ 1000000 │ ' 14098 ms' │ ' 2352 ms' │ ' 2015 ms' │ ' 1.17 x' │
1263
+ │ Array_ObjectB │ 1000000 │ ' 16216 ms' │ ' 2628 ms' │ ' 2511 ms' │ ' 1.05 x' │
1264
+ │ Array_Tuple │ 1000000 │ ' 1749 ms' │ ' 95 ms' │ ' 75 ms' │ ' 1.27 x' │
1265
+ │ Array_Union │ 1000000 │ ' 4712 ms' │ ' 233 ms' │ ' 84 ms' │ ' 2.77 x' │
1266
+ │ Array_Recursive │ 1000000 │ ' 56118 ms' │ ' 7192 ms' │ ' 1180 ms' │ ' 6.09 x' │
1267
+ │ Array_Vector4 │ 1000000 │ ' 2284 ms' │ ' 99 ms' │ ' 50 ms' │ ' 1.98 x' │
1268
+ │ Array_Matrix4 │ 1000000 │ ' 12640 ms' │ ' 412 ms' │ ' 272 ms' │ ' 1.51 x' │
1269
1269
  └──────────────────┴────────────┴──────────────┴──────────────┴──────────────┴──────────────┘
1270
1270
  ```
1271
1271
 
package/value/cast.js CHANGED
@@ -137,7 +137,7 @@ var ValueCast;
137
137
  return typeof value === 'bigint';
138
138
  }
139
139
  function IsNumber(value) {
140
- return typeof value === 'number';
140
+ return typeof value === 'number' && !isNaN(value);
141
141
  }
142
142
  function IsStringNumeric(value) {
143
143
  return IsString(value) && !isNaN(value) && !isNaN(parseFloat(value));
package/value/check.js CHANGED
@@ -42,7 +42,7 @@ exports.ValueCheckUnknownTypeError = ValueCheckUnknownTypeError;
42
42
  var ValueCheck;
43
43
  (function (ValueCheck) {
44
44
  function IsNumber(value) {
45
- return typeof value === 'number';
45
+ return typeof value === 'number' && !isNaN(value);
46
46
  }
47
47
  function Any(schema, references, value) {
48
48
  return true;
@@ -99,7 +99,7 @@ var ValueCheck;
99
99
  return typeof value === 'function';
100
100
  }
101
101
  function Integer(schema, references, value) {
102
- if (!(typeof value === 'number')) {
102
+ if (!(typeof value === 'number' && globalThis.Number.isInteger(value))) {
103
103
  return false;
104
104
  }
105
105
  if (!globalThis.Number.isInteger(value)) {
@@ -132,7 +132,7 @@ var ValueCheck;
132
132
  return value === null;
133
133
  }
134
134
  function Number(schema, references, value) {
135
- if (!(typeof value === 'number')) {
135
+ if (!(typeof value === 'number' && !isNaN(value))) {
136
136
  return false;
137
137
  }
138
138
  if (IsNumber(schema.multipleOf) && !(value % schema.multipleOf === 0)) {
package/value/create.js CHANGED
@@ -131,13 +131,23 @@ var ValueCreate;
131
131
  }
132
132
  }
133
133
  function Literal(schema, references) {
134
- return schema.const;
134
+ if (schema.default !== undefined) {
135
+ return schema.default;
136
+ }
137
+ else {
138
+ return schema.const;
139
+ }
135
140
  }
136
141
  function Never(schema, references) {
137
142
  throw new ValueCreateNeverTypeError(schema);
138
143
  }
139
144
  function Null(schema, references) {
140
- return null;
145
+ if (schema.default !== undefined) {
146
+ return schema.default;
147
+ }
148
+ else {
149
+ return null;
150
+ }
141
151
  }
142
152
  function Number(schema, references) {
143
153
  if (schema.default !== undefined) {
@@ -258,7 +268,12 @@ var ValueCreate;
258
268
  }
259
269
  }
260
270
  function Undefined(schema, references) {
261
- return undefined;
271
+ if (schema.default !== undefined) {
272
+ return schema.default;
273
+ }
274
+ else {
275
+ return undefined;
276
+ }
262
277
  }
263
278
  function Union(schema, references) {
264
279
  if (schema.default !== undefined) {
@@ -291,7 +306,12 @@ var ValueCreate;
291
306
  }
292
307
  }
293
308
  function Void(schema, references) {
294
- return null;
309
+ if (schema.default !== undefined) {
310
+ return schema.default;
311
+ }
312
+ else {
313
+ return null;
314
+ }
295
315
  }
296
316
  function UserDefined(schema, references) {
297
317
  if (schema.default !== undefined) {