@e22m4u/js-repository 0.1.3 → 0.1.5

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.
Files changed (113) hide show
  1. package/README.md +33 -33
  2. package/assets/mermaid-diagram.png +0 -0
  3. package/assets/mermaid-diagram.txt +29 -0
  4. package/docs/assets/main.js +4 -4
  5. package/docs/assets/navigation.js +1 -1
  6. package/docs/assets/search.js +1 -1
  7. package/docs/classes/Adapter.html +14 -14
  8. package/docs/classes/AdapterLoader.html +2 -2
  9. package/docs/classes/AdapterRegistry.html +2 -2
  10. package/docs/classes/BelongsToResolver.html +3 -3
  11. package/docs/classes/DatasourceDefinitionValidator.html +2 -2
  12. package/docs/classes/DefinitionRegistry.html +7 -7
  13. package/docs/classes/FieldsClauseTool.html +4 -4
  14. package/docs/classes/HasManyResolver.html +4 -4
  15. package/docs/classes/HasOneResolver.html +4 -4
  16. package/docs/classes/IncludeClauseTool.html +6 -6
  17. package/docs/classes/InvalidArgumentError.html +1 -1
  18. package/docs/classes/InvalidOperatorValueError.html +2 -2
  19. package/docs/classes/ModelDataSanitizer.html +2 -2
  20. package/docs/classes/ModelDataValidator.html +3 -5
  21. package/docs/classes/ModelDefinitionUtils.html +17 -17
  22. package/docs/classes/ModelDefinitionValidator.html +2 -2
  23. package/docs/classes/NotImplementedError.html +1 -1
  24. package/docs/classes/OperatorClauseTool.html +14 -14
  25. package/docs/classes/OrderClauseTool.html +4 -4
  26. package/docs/classes/PrimaryKeysDefinitionValidator.html +2 -2
  27. package/docs/classes/PropertiesDefinitionValidator.html +2 -2
  28. package/docs/classes/PropertyValidatorRegistry.html +20 -0
  29. package/docs/classes/ReferencesManyResolver.html +2 -2
  30. package/docs/classes/RelationsDefinitionValidator.html +2 -2
  31. package/docs/classes/Repository.html +17 -17
  32. package/docs/classes/RepositoryRegistry.html +3 -3
  33. package/docs/classes/Schema.html +4 -4
  34. package/docs/classes/SliceClauseTool.html +4 -4
  35. package/docs/classes/WhereClauseTool.html +3 -3
  36. package/docs/enums/DataType.html +2 -2
  37. package/docs/enums/DecoratorTargetType.html +2 -2
  38. package/docs/enums/RelationType.html +2 -2
  39. package/docs/functions/capitalize.html +1 -1
  40. package/docs/functions/cloneDeep.html +1 -1
  41. package/docs/functions/excludeObjectKeys.html +1 -1
  42. package/docs/functions/getCtorName.html +1 -1
  43. package/docs/functions/getDecoratorTargetType.html +1 -1
  44. package/docs/functions/getValueByPath.html +1 -1
  45. package/docs/functions/isCtor.html +1 -1
  46. package/docs/functions/isPureObject.html +1 -1
  47. package/docs/functions/selectObjectKeys.html +1 -1
  48. package/docs/functions/singularize.html +1 -1
  49. package/docs/functions/stringToRegexp.html +1 -1
  50. package/docs/index.html +18 -4
  51. package/docs/interfaces/AndClause.html +2 -2
  52. package/docs/interfaces/Constructor.html +2 -2
  53. package/docs/interfaces/OrClause.html +2 -2
  54. package/docs/modules.html +4 -0
  55. package/docs/types/AnyObject.html +1 -1
  56. package/docs/types/BelongsToDefinition.html +1 -1
  57. package/docs/types/DEFAULT_PRIMARY_KEY_PROPERTY_NAME.html +1 -1
  58. package/docs/types/DatasourceDefinition.html +1 -1
  59. package/docs/types/FieldsClause.html +1 -1
  60. package/docs/types/FilterClause.html +1 -1
  61. package/docs/types/Flatten.html +1 -1
  62. package/docs/types/FullPropertyDefinition.html +2 -2
  63. package/docs/types/HasManyDefinition.html +1 -1
  64. package/docs/types/HasOneDefinition.html +1 -1
  65. package/docs/types/Identity.html +1 -1
  66. package/docs/types/IncludeClause.html +1 -1
  67. package/docs/types/ItemFilterClause.html +1 -1
  68. package/docs/types/ModelData.html +1 -1
  69. package/docs/types/ModelDefinition.html +1 -1
  70. package/docs/types/ModelId.html +1 -1
  71. package/docs/types/NestedIncludeClause.html +1 -1
  72. package/docs/types/NormalizedFieldsClause.html +1 -1
  73. package/docs/types/NormalizedIncludeClause.html +1 -1
  74. package/docs/types/OperatorClause.html +1 -1
  75. package/docs/types/OptionalUnlessRequiredId.html +1 -1
  76. package/docs/types/OrderClause.html +1 -1
  77. package/docs/types/PartialBy.html +1 -1
  78. package/docs/types/PartialWithoutId.html +1 -1
  79. package/docs/types/PolyBelongsToDefinition.html +1 -1
  80. package/docs/types/PolyHasManyDefinitionWithTargetKeys.html +1 -1
  81. package/docs/types/PolyHasManyDefinitionWithTargetRelationName.html +1 -1
  82. package/docs/types/PolyHasOneDefinitionWithTargetKeys.html +1 -1
  83. package/docs/types/PolyHasOneDefinitionWithTargetRelationName.html +1 -1
  84. package/docs/types/PropertiesClause.html +1 -1
  85. package/docs/types/PropertyDefinition.html +1 -1
  86. package/docs/types/PropertyDefinitionMap.html +1 -1
  87. package/docs/types/PropertyValidateOptions.html +2 -0
  88. package/docs/types/PropertyValidator.html +2 -0
  89. package/docs/types/PropertyValidatorContext.html +2 -0
  90. package/docs/types/ReferencesManyDefinition.html +1 -1
  91. package/docs/types/RelationDefinition.html +1 -1
  92. package/docs/types/RelationDefinitionMap.html +1 -1
  93. package/docs/types/WhereClause.html +1 -1
  94. package/docs/types/WithoutId.html +1 -1
  95. package/package.json +2 -2
  96. package/src/definition/model/model-data-validator.js +7 -17
  97. package/src/definition/model/model-data-validator.spec.js +1577 -1543
  98. package/src/definition/model/properties/property-validator/builtin/index.d.ts +3 -0
  99. package/src/definition/model/properties/property-validator/builtin/index.js +3 -0
  100. package/src/definition/model/properties/property-validator/builtin/max-length-validator.d.ts +6 -0
  101. package/src/definition/model/properties/property-validator/builtin/max-length-validator.js +28 -0
  102. package/src/definition/model/properties/property-validator/builtin/max-length-validator.spec.js +93 -0
  103. package/src/definition/model/properties/property-validator/builtin/min-length-validator.d.ts +6 -0
  104. package/src/definition/model/properties/property-validator/builtin/min-length-validator.js +28 -0
  105. package/src/definition/model/properties/property-validator/builtin/min-length-validator.spec.js +93 -0
  106. package/src/definition/model/properties/property-validator/builtin/regexp-validator.d.ts +6 -0
  107. package/src/definition/model/properties/property-validator/builtin/regexp-validator.js +30 -0
  108. package/src/definition/model/properties/property-validator/builtin/regexp-validator.spec.js +95 -0
  109. package/src/definition/model/properties/property-validator/property-validator-registry.js +8 -1
  110. package/src/definition/model/properties/property-validator/property-validator-registry.spec.js +1 -1
  111. package/src/schema.d.ts +0 -9
  112. package/src/schema.js +0 -13
  113. package/src/schema.spec.ts +0 -29
@@ -174,1780 +174,1782 @@ describe('ModelDataValidator', function () {
174
174
  });
175
175
  });
176
176
 
177
- describe('DataType.ANY', function () {
178
- describe('ShortPropertyDefinition', function () {
179
- it('does not throw an error if an undefined given', async function () {
180
- const S = new Schema();
181
- S.defineModel({
182
- name: 'model',
183
- datasource: 'datasource',
184
- properties: {
185
- foo: DataType.ANY,
186
- },
187
- });
188
- await S.getService(ModelDataValidator).validate('model', {
189
- foo: undefined,
177
+ describe('validate by property type', function () {
178
+ describe('DataType.ANY', function () {
179
+ describe('ShortPropertyDefinition', function () {
180
+ it('does not throw an error if an undefined given', async function () {
181
+ const S = new Schema();
182
+ S.defineModel({
183
+ name: 'model',
184
+ datasource: 'datasource',
185
+ properties: {
186
+ foo: DataType.ANY,
187
+ },
188
+ });
189
+ await S.getService(ModelDataValidator).validate('model', {
190
+ foo: undefined,
191
+ });
190
192
  });
191
- });
192
193
 
193
- it('does not throw an error if a null given', async function () {
194
- const S = new Schema();
195
- S.defineModel({
196
- name: 'model',
197
- datasource: 'datasource',
198
- properties: {
199
- foo: DataType.ANY,
200
- },
201
- });
202
- await S.getService(ModelDataValidator).validate('model', {
203
- foo: null,
194
+ it('does not throw an error if a null given', async function () {
195
+ const S = new Schema();
196
+ S.defineModel({
197
+ name: 'model',
198
+ datasource: 'datasource',
199
+ properties: {
200
+ foo: DataType.ANY,
201
+ },
202
+ });
203
+ await S.getService(ModelDataValidator).validate('model', {
204
+ foo: null,
205
+ });
204
206
  });
205
- });
206
207
 
207
- it('does not throw an error if a string given', async function () {
208
- const S = new Schema();
209
- S.defineModel({
210
- name: 'model',
211
- datasource: 'datasource',
212
- properties: {
213
- foo: DataType.ANY,
214
- },
215
- });
216
- await S.getService(ModelDataValidator).validate('model', {
217
- foo: 'bar',
208
+ it('does not throw an error if a string given', async function () {
209
+ const S = new Schema();
210
+ S.defineModel({
211
+ name: 'model',
212
+ datasource: 'datasource',
213
+ properties: {
214
+ foo: DataType.ANY,
215
+ },
216
+ });
217
+ await S.getService(ModelDataValidator).validate('model', {
218
+ foo: 'bar',
219
+ });
218
220
  });
219
- });
220
221
 
221
- it('does not throw an error if a number given', async function () {
222
- const S = new Schema();
223
- S.defineModel({
224
- name: 'model',
225
- datasource: 'datasource',
226
- properties: {
227
- foo: DataType.ANY,
228
- },
229
- });
230
- await S.getService(ModelDataValidator).validate('model', {
231
- foo: 10,
222
+ it('does not throw an error if a number given', async function () {
223
+ const S = new Schema();
224
+ S.defineModel({
225
+ name: 'model',
226
+ datasource: 'datasource',
227
+ properties: {
228
+ foo: DataType.ANY,
229
+ },
230
+ });
231
+ await S.getService(ModelDataValidator).validate('model', {
232
+ foo: 10,
233
+ });
232
234
  });
233
- });
234
235
 
235
- it('does not throw an error if true given', async function () {
236
- const S = new Schema();
237
- S.defineModel({
238
- name: 'model',
239
- datasource: 'datasource',
240
- properties: {
241
- foo: DataType.ANY,
242
- },
243
- });
244
- await S.getService(ModelDataValidator).validate('model', {
245
- foo: true,
236
+ it('does not throw an error if true given', async function () {
237
+ const S = new Schema();
238
+ S.defineModel({
239
+ name: 'model',
240
+ datasource: 'datasource',
241
+ properties: {
242
+ foo: DataType.ANY,
243
+ },
244
+ });
245
+ await S.getService(ModelDataValidator).validate('model', {
246
+ foo: true,
247
+ });
246
248
  });
247
- });
248
249
 
249
- it('does not throw an error if false given', async function () {
250
- const S = new Schema();
251
- S.defineModel({
252
- name: 'model',
253
- datasource: 'datasource',
254
- properties: {
255
- foo: DataType.ANY,
256
- },
257
- });
258
- await S.getService(ModelDataValidator).validate('model', {
259
- foo: false,
250
+ it('does not throw an error if false given', async function () {
251
+ const S = new Schema();
252
+ S.defineModel({
253
+ name: 'model',
254
+ datasource: 'datasource',
255
+ properties: {
256
+ foo: DataType.ANY,
257
+ },
258
+ });
259
+ await S.getService(ModelDataValidator).validate('model', {
260
+ foo: false,
261
+ });
260
262
  });
261
- });
262
263
 
263
- it('does not throw an error if an array given', async function () {
264
- const S = new Schema();
265
- S.defineModel({
266
- name: 'model',
267
- datasource: 'datasource',
268
- properties: {
269
- foo: DataType.ANY,
270
- },
271
- });
272
- await S.getService(ModelDataValidator).validate('model', {
273
- foo: [],
264
+ it('does not throw an error if an array given', async function () {
265
+ const S = new Schema();
266
+ S.defineModel({
267
+ name: 'model',
268
+ datasource: 'datasource',
269
+ properties: {
270
+ foo: DataType.ANY,
271
+ },
272
+ });
273
+ await S.getService(ModelDataValidator).validate('model', {
274
+ foo: [],
275
+ });
274
276
  });
275
- });
276
277
 
277
- it('does not throw an error if an object given', async function () {
278
- const S = new Schema();
279
- S.defineModel({
280
- name: 'model',
281
- datasource: 'datasource',
282
- properties: {
283
- foo: DataType.ANY,
284
- },
285
- });
286
- await S.getService(ModelDataValidator).validate('model', {
287
- foo: {},
278
+ it('does not throw an error if an object given', async function () {
279
+ const S = new Schema();
280
+ S.defineModel({
281
+ name: 'model',
282
+ datasource: 'datasource',
283
+ properties: {
284
+ foo: DataType.ANY,
285
+ },
286
+ });
287
+ await S.getService(ModelDataValidator).validate('model', {
288
+ foo: {},
289
+ });
288
290
  });
289
291
  });
290
- });
291
292
 
292
- describe('FullPropertyDefinition', function () {
293
- it('does not throw an error if an undefined given', async function () {
294
- const S = new Schema();
295
- S.defineModel({
296
- name: 'model',
297
- datasource: 'datasource',
298
- properties: {
299
- foo: {
300
- type: DataType.ANY,
293
+ describe('FullPropertyDefinition', function () {
294
+ it('does not throw an error if an undefined given', async function () {
295
+ const S = new Schema();
296
+ S.defineModel({
297
+ name: 'model',
298
+ datasource: 'datasource',
299
+ properties: {
300
+ foo: {
301
+ type: DataType.ANY,
302
+ },
301
303
  },
302
- },
303
- });
304
- await S.getService(ModelDataValidator).validate('model', {
305
- foo: undefined,
304
+ });
305
+ await S.getService(ModelDataValidator).validate('model', {
306
+ foo: undefined,
307
+ });
306
308
  });
307
- });
308
309
 
309
- it('does not throw an error if a null given', async function () {
310
- const S = new Schema();
311
- S.defineModel({
312
- name: 'model',
313
- datasource: 'datasource',
314
- properties: {
315
- foo: {
316
- type: DataType.ANY,
310
+ it('does not throw an error if a null given', async function () {
311
+ const S = new Schema();
312
+ S.defineModel({
313
+ name: 'model',
314
+ datasource: 'datasource',
315
+ properties: {
316
+ foo: {
317
+ type: DataType.ANY,
318
+ },
317
319
  },
318
- },
319
- });
320
- await S.getService(ModelDataValidator).validate('model', {
321
- foo: null,
320
+ });
321
+ await S.getService(ModelDataValidator).validate('model', {
322
+ foo: null,
323
+ });
322
324
  });
323
- });
324
325
 
325
- it('does not throw an error if a string given', async function () {
326
- const S = new Schema();
327
- S.defineModel({
328
- name: 'model',
329
- datasource: 'datasource',
330
- properties: {
331
- foo: {
332
- type: DataType.ANY,
326
+ it('does not throw an error if a string given', async function () {
327
+ const S = new Schema();
328
+ S.defineModel({
329
+ name: 'model',
330
+ datasource: 'datasource',
331
+ properties: {
332
+ foo: {
333
+ type: DataType.ANY,
334
+ },
333
335
  },
334
- },
335
- });
336
- await S.getService(ModelDataValidator).validate('model', {
337
- foo: 'bar',
336
+ });
337
+ await S.getService(ModelDataValidator).validate('model', {
338
+ foo: 'bar',
339
+ });
338
340
  });
339
- });
340
341
 
341
- it('does not throw an error if a number given', async function () {
342
- const S = new Schema();
343
- S.defineModel({
344
- name: 'model',
345
- datasource: 'datasource',
346
- properties: {
347
- foo: {
348
- type: DataType.ANY,
342
+ it('does not throw an error if a number given', async function () {
343
+ const S = new Schema();
344
+ S.defineModel({
345
+ name: 'model',
346
+ datasource: 'datasource',
347
+ properties: {
348
+ foo: {
349
+ type: DataType.ANY,
350
+ },
349
351
  },
350
- },
351
- });
352
- await S.getService(ModelDataValidator).validate('model', {
353
- foo: 10,
352
+ });
353
+ await S.getService(ModelDataValidator).validate('model', {
354
+ foo: 10,
355
+ });
354
356
  });
355
- });
356
357
 
357
- it('does not throw an error if true given', async function () {
358
- const S = new Schema();
359
- S.defineModel({
360
- name: 'model',
361
- datasource: 'datasource',
362
- properties: {
363
- foo: {
364
- type: DataType.ANY,
358
+ it('does not throw an error if true given', async function () {
359
+ const S = new Schema();
360
+ S.defineModel({
361
+ name: 'model',
362
+ datasource: 'datasource',
363
+ properties: {
364
+ foo: {
365
+ type: DataType.ANY,
366
+ },
365
367
  },
366
- },
367
- });
368
- await S.getService(ModelDataValidator).validate('model', {
369
- foo: true,
368
+ });
369
+ await S.getService(ModelDataValidator).validate('model', {
370
+ foo: true,
371
+ });
370
372
  });
371
- });
372
373
 
373
- it('does not throw an error if false given', async function () {
374
- const S = new Schema();
375
- S.defineModel({
376
- name: 'model',
377
- datasource: 'datasource',
378
- properties: {
379
- foo: {
380
- type: DataType.ANY,
374
+ it('does not throw an error if false given', async function () {
375
+ const S = new Schema();
376
+ S.defineModel({
377
+ name: 'model',
378
+ datasource: 'datasource',
379
+ properties: {
380
+ foo: {
381
+ type: DataType.ANY,
382
+ },
381
383
  },
382
- },
383
- });
384
- await S.getService(ModelDataValidator).validate('model', {
385
- foo: false,
384
+ });
385
+ await S.getService(ModelDataValidator).validate('model', {
386
+ foo: false,
387
+ });
386
388
  });
387
- });
388
389
 
389
- it('does not throw an error if an array given', async function () {
390
- const S = new Schema();
391
- S.defineModel({
392
- name: 'model',
393
- datasource: 'datasource',
394
- properties: {
395
- foo: {
396
- type: DataType.ANY,
390
+ it('does not throw an error if an array given', async function () {
391
+ const S = new Schema();
392
+ S.defineModel({
393
+ name: 'model',
394
+ datasource: 'datasource',
395
+ properties: {
396
+ foo: {
397
+ type: DataType.ANY,
398
+ },
397
399
  },
398
- },
399
- });
400
- await S.getService(ModelDataValidator).validate('model', {
401
- foo: [],
400
+ });
401
+ await S.getService(ModelDataValidator).validate('model', {
402
+ foo: [],
403
+ });
402
404
  });
403
- });
404
405
 
405
- it('does not throw an error if an object given', async function () {
406
- const S = new Schema();
407
- S.defineModel({
408
- name: 'model',
409
- datasource: 'datasource',
410
- properties: {
411
- foo: {
412
- type: DataType.ANY,
406
+ it('does not throw an error if an object given', async function () {
407
+ const S = new Schema();
408
+ S.defineModel({
409
+ name: 'model',
410
+ datasource: 'datasource',
411
+ properties: {
412
+ foo: {
413
+ type: DataType.ANY,
414
+ },
413
415
  },
414
- },
415
- });
416
- await S.getService(ModelDataValidator).validate('model', {
417
- foo: {},
416
+ });
417
+ await S.getService(ModelDataValidator).validate('model', {
418
+ foo: {},
419
+ });
418
420
  });
419
421
  });
420
422
  });
421
- });
422
-
423
- describe('DataType.STRING', function () {
424
- describe('ShortPropertyDefinition', function () {
425
- it('does not throw an error if an undefined given', async function () {
426
- const S = new Schema();
427
- S.defineModel({
428
- name: 'model',
429
- datasource: 'datasource',
430
- properties: {
431
- foo: DataType.STRING,
432
- },
433
- });
434
- await S.getService(ModelDataValidator).validate('model', {
435
- foo: undefined,
436
- });
437
- });
438
423
 
439
- it('does not throw an error if a null given', async function () {
440
- const S = new Schema();
441
- S.defineModel({
442
- name: 'model',
443
- datasource: 'datasource',
444
- properties: {
445
- foo: DataType.STRING,
446
- },
447
- });
448
- await S.getService(ModelDataValidator).validate('model', {
449
- foo: null,
424
+ describe('DataType.STRING', function () {
425
+ describe('ShortPropertyDefinition', function () {
426
+ it('does not throw an error if an undefined given', async function () {
427
+ const S = new Schema();
428
+ S.defineModel({
429
+ name: 'model',
430
+ datasource: 'datasource',
431
+ properties: {
432
+ foo: DataType.STRING,
433
+ },
434
+ });
435
+ await S.getService(ModelDataValidator).validate('model', {
436
+ foo: undefined,
437
+ });
450
438
  });
451
- });
452
439
 
453
- it('does not throw an error if a string given', async function () {
454
- const S = new Schema();
455
- S.defineModel({
456
- name: 'model',
457
- datasource: 'datasource',
458
- properties: {
459
- foo: DataType.STRING,
460
- },
461
- });
462
- await S.getService(ModelDataValidator).validate('model', {
463
- foo: 'bar',
440
+ it('does not throw an error if a null given', async function () {
441
+ const S = new Schema();
442
+ S.defineModel({
443
+ name: 'model',
444
+ datasource: 'datasource',
445
+ properties: {
446
+ foo: DataType.STRING,
447
+ },
448
+ });
449
+ await S.getService(ModelDataValidator).validate('model', {
450
+ foo: null,
451
+ });
464
452
  });
465
- });
466
453
 
467
- it('throws an error if a number given', async function () {
468
- const S = new Schema();
469
- S.defineModel({
470
- name: 'model',
471
- datasource: 'datasource',
472
- properties: {
473
- foo: DataType.STRING,
474
- },
475
- });
476
- const promise = S.getService(ModelDataValidator).validate('model', {
477
- foo: 10,
454
+ it('does not throw an error if a string given', async function () {
455
+ const S = new Schema();
456
+ S.defineModel({
457
+ name: 'model',
458
+ datasource: 'datasource',
459
+ properties: {
460
+ foo: DataType.STRING,
461
+ },
462
+ });
463
+ await S.getService(ModelDataValidator).validate('model', {
464
+ foo: 'bar',
465
+ });
478
466
  });
479
- await expect(promise).to.be.rejectedWith(
480
- 'The property "foo" of the model "model" must have ' +
481
- 'a String, but Number given.',
482
- );
483
- });
484
467
 
485
- it('throws an error if true given', async function () {
486
- const S = new Schema();
487
- S.defineModel({
488
- name: 'model',
489
- datasource: 'datasource',
490
- properties: {
491
- foo: DataType.STRING,
492
- },
493
- });
494
- const promise = S.getService(ModelDataValidator).validate('model', {
495
- foo: true,
468
+ it('throws an error if a number given', async function () {
469
+ const S = new Schema();
470
+ S.defineModel({
471
+ name: 'model',
472
+ datasource: 'datasource',
473
+ properties: {
474
+ foo: DataType.STRING,
475
+ },
476
+ });
477
+ const promise = S.getService(ModelDataValidator).validate('model', {
478
+ foo: 10,
479
+ });
480
+ await expect(promise).to.be.rejectedWith(
481
+ 'The property "foo" of the model "model" must have ' +
482
+ 'a String, but Number given.',
483
+ );
496
484
  });
497
- await expect(promise).to.be.rejectedWith(
498
- 'The property "foo" of the model "model" must have ' +
499
- 'a String, but Boolean given.',
500
- );
501
- });
502
485
 
503
- it('throws an error if false given', async function () {
504
- const S = new Schema();
505
- S.defineModel({
506
- name: 'model',
507
- datasource: 'datasource',
508
- properties: {
509
- foo: DataType.STRING,
510
- },
511
- });
512
- const promise = S.getService(ModelDataValidator).validate('model', {
513
- foo: false,
486
+ it('throws an error if true given', async function () {
487
+ const S = new Schema();
488
+ S.defineModel({
489
+ name: 'model',
490
+ datasource: 'datasource',
491
+ properties: {
492
+ foo: DataType.STRING,
493
+ },
494
+ });
495
+ const promise = S.getService(ModelDataValidator).validate('model', {
496
+ foo: true,
497
+ });
498
+ await expect(promise).to.be.rejectedWith(
499
+ 'The property "foo" of the model "model" must have ' +
500
+ 'a String, but Boolean given.',
501
+ );
514
502
  });
515
- await expect(promise).to.be.rejectedWith(
516
- 'The property "foo" of the model "model" must have ' +
517
- 'a String, but Boolean given.',
518
- );
519
- });
520
503
 
521
- it('throws an error if an array given', async function () {
522
- const S = new Schema();
523
- S.defineModel({
524
- name: 'model',
525
- datasource: 'datasource',
526
- properties: {
527
- foo: DataType.STRING,
528
- },
529
- });
530
- const promise = S.getService(ModelDataValidator).validate('model', {
531
- foo: [],
504
+ it('throws an error if false given', async function () {
505
+ const S = new Schema();
506
+ S.defineModel({
507
+ name: 'model',
508
+ datasource: 'datasource',
509
+ properties: {
510
+ foo: DataType.STRING,
511
+ },
512
+ });
513
+ const promise = S.getService(ModelDataValidator).validate('model', {
514
+ foo: false,
515
+ });
516
+ await expect(promise).to.be.rejectedWith(
517
+ 'The property "foo" of the model "model" must have ' +
518
+ 'a String, but Boolean given.',
519
+ );
532
520
  });
533
- await expect(promise).to.be.rejectedWith(
534
- 'The property "foo" of the model "model" must have ' +
535
- 'a String, but Array given.',
536
- );
537
- });
538
521
 
539
- it('throws an error if an object given', async function () {
540
- const S = new Schema();
541
- S.defineModel({
542
- name: 'model',
543
- datasource: 'datasource',
544
- properties: {
545
- foo: DataType.STRING,
546
- },
547
- });
548
- const promise = S.getService(ModelDataValidator).validate('model', {
549
- foo: {},
522
+ it('throws an error if an array given', async function () {
523
+ const S = new Schema();
524
+ S.defineModel({
525
+ name: 'model',
526
+ datasource: 'datasource',
527
+ properties: {
528
+ foo: DataType.STRING,
529
+ },
530
+ });
531
+ const promise = S.getService(ModelDataValidator).validate('model', {
532
+ foo: [],
533
+ });
534
+ await expect(promise).to.be.rejectedWith(
535
+ 'The property "foo" of the model "model" must have ' +
536
+ 'a String, but Array given.',
537
+ );
550
538
  });
551
- await expect(promise).to.be.rejectedWith(
552
- 'The property "foo" of the model "model" must have ' +
553
- 'a String, but Object given.',
554
- );
555
- });
556
- });
557
539
 
558
- describe('FullPropertyDefinition', function () {
559
- it('does not throw an error if an undefined given', async function () {
560
- const S = new Schema();
561
- S.defineModel({
562
- name: 'model',
563
- datasource: 'datasource',
564
- properties: {
565
- foo: {
566
- type: DataType.STRING,
540
+ it('throws an error if an object given', async function () {
541
+ const S = new Schema();
542
+ S.defineModel({
543
+ name: 'model',
544
+ datasource: 'datasource',
545
+ properties: {
546
+ foo: DataType.STRING,
567
547
  },
568
- },
569
- });
570
- await S.getService(ModelDataValidator).validate('model', {
571
- foo: undefined,
548
+ });
549
+ const promise = S.getService(ModelDataValidator).validate('model', {
550
+ foo: {},
551
+ });
552
+ await expect(promise).to.be.rejectedWith(
553
+ 'The property "foo" of the model "model" must have ' +
554
+ 'a String, but Object given.',
555
+ );
572
556
  });
573
557
  });
574
558
 
575
- it('does not throw an error if a null given', async function () {
576
- const S = new Schema();
577
- S.defineModel({
578
- name: 'model',
579
- datasource: 'datasource',
580
- properties: {
581
- foo: {
582
- type: DataType.STRING,
559
+ describe('FullPropertyDefinition', function () {
560
+ it('does not throw an error if an undefined given', async function () {
561
+ const S = new Schema();
562
+ S.defineModel({
563
+ name: 'model',
564
+ datasource: 'datasource',
565
+ properties: {
566
+ foo: {
567
+ type: DataType.STRING,
568
+ },
583
569
  },
584
- },
585
- });
586
- await S.getService(ModelDataValidator).validate('model', {
587
- foo: null,
570
+ });
571
+ await S.getService(ModelDataValidator).validate('model', {
572
+ foo: undefined,
573
+ });
588
574
  });
589
- });
590
575
 
591
- it('does not throw an error if a string given', async function () {
592
- const S = new Schema();
593
- S.defineModel({
594
- name: 'model',
595
- datasource: 'datasource',
596
- properties: {
597
- foo: {
598
- type: DataType.STRING,
576
+ it('does not throw an error if a null given', async function () {
577
+ const S = new Schema();
578
+ S.defineModel({
579
+ name: 'model',
580
+ datasource: 'datasource',
581
+ properties: {
582
+ foo: {
583
+ type: DataType.STRING,
584
+ },
599
585
  },
600
- },
601
- });
602
- await S.getService(ModelDataValidator).validate('model', {
603
- foo: 'bar',
586
+ });
587
+ await S.getService(ModelDataValidator).validate('model', {
588
+ foo: null,
589
+ });
604
590
  });
605
- });
606
591
 
607
- it('throws an error if a number given', async function () {
608
- const S = new Schema();
609
- S.defineModel({
610
- name: 'model',
611
- datasource: 'datasource',
612
- properties: {
613
- foo: {
614
- type: DataType.STRING,
592
+ it('does not throw an error if a string given', async function () {
593
+ const S = new Schema();
594
+ S.defineModel({
595
+ name: 'model',
596
+ datasource: 'datasource',
597
+ properties: {
598
+ foo: {
599
+ type: DataType.STRING,
600
+ },
615
601
  },
616
- },
617
- });
618
- const promise = S.getService(ModelDataValidator).validate('model', {
619
- foo: 10,
602
+ });
603
+ await S.getService(ModelDataValidator).validate('model', {
604
+ foo: 'bar',
605
+ });
620
606
  });
621
- await expect(promise).to.be.rejectedWith(
622
- 'The property "foo" of the model "model" must have ' +
623
- 'a String, but Number given.',
624
- );
625
- });
626
607
 
627
- it('throws an error if true given', async function () {
628
- const S = new Schema();
629
- S.defineModel({
630
- name: 'model',
631
- datasource: 'datasource',
632
- properties: {
633
- foo: {
634
- type: DataType.STRING,
608
+ it('throws an error if a number given', async function () {
609
+ const S = new Schema();
610
+ S.defineModel({
611
+ name: 'model',
612
+ datasource: 'datasource',
613
+ properties: {
614
+ foo: {
615
+ type: DataType.STRING,
616
+ },
635
617
  },
636
- },
637
- });
638
- const promise = S.getService(ModelDataValidator).validate('model', {
639
- foo: true,
618
+ });
619
+ const promise = S.getService(ModelDataValidator).validate('model', {
620
+ foo: 10,
621
+ });
622
+ await expect(promise).to.be.rejectedWith(
623
+ 'The property "foo" of the model "model" must have ' +
624
+ 'a String, but Number given.',
625
+ );
640
626
  });
641
- await expect(promise).to.be.rejectedWith(
642
- 'The property "foo" of the model "model" must have ' +
643
- 'a String, but Boolean given.',
644
- );
645
- });
646
627
 
647
- it('throws an error if false given', async function () {
648
- const S = new Schema();
649
- S.defineModel({
650
- name: 'model',
651
- datasource: 'datasource',
652
- properties: {
653
- foo: {
654
- type: DataType.STRING,
628
+ it('throws an error if true given', async function () {
629
+ const S = new Schema();
630
+ S.defineModel({
631
+ name: 'model',
632
+ datasource: 'datasource',
633
+ properties: {
634
+ foo: {
635
+ type: DataType.STRING,
636
+ },
655
637
  },
656
- },
657
- });
658
- const promise = S.getService(ModelDataValidator).validate('model', {
659
- foo: false,
638
+ });
639
+ const promise = S.getService(ModelDataValidator).validate('model', {
640
+ foo: true,
641
+ });
642
+ await expect(promise).to.be.rejectedWith(
643
+ 'The property "foo" of the model "model" must have ' +
644
+ 'a String, but Boolean given.',
645
+ );
660
646
  });
661
- await expect(promise).to.be.rejectedWith(
662
- 'The property "foo" of the model "model" must have ' +
663
- 'a String, but Boolean given.',
664
- );
665
- });
666
647
 
667
- it('throws an error if an array given', async function () {
668
- const S = new Schema();
669
- S.defineModel({
670
- name: 'model',
671
- datasource: 'datasource',
672
- properties: {
673
- foo: {
674
- type: DataType.STRING,
648
+ it('throws an error if false given', async function () {
649
+ const S = new Schema();
650
+ S.defineModel({
651
+ name: 'model',
652
+ datasource: 'datasource',
653
+ properties: {
654
+ foo: {
655
+ type: DataType.STRING,
656
+ },
675
657
  },
676
- },
677
- });
678
- const promise = S.getService(ModelDataValidator).validate('model', {
679
- foo: [],
658
+ });
659
+ const promise = S.getService(ModelDataValidator).validate('model', {
660
+ foo: false,
661
+ });
662
+ await expect(promise).to.be.rejectedWith(
663
+ 'The property "foo" of the model "model" must have ' +
664
+ 'a String, but Boolean given.',
665
+ );
680
666
  });
681
- await expect(promise).to.be.rejectedWith(
682
- 'The property "foo" of the model "model" must have ' +
683
- 'a String, but Array given.',
684
- );
685
- });
686
667
 
687
- it('throws an error if an object given', async function () {
688
- const S = new Schema();
689
- S.defineModel({
690
- name: 'model',
691
- datasource: 'datasource',
692
- properties: {
693
- foo: {
694
- type: DataType.STRING,
668
+ it('throws an error if an array given', async function () {
669
+ const S = new Schema();
670
+ S.defineModel({
671
+ name: 'model',
672
+ datasource: 'datasource',
673
+ properties: {
674
+ foo: {
675
+ type: DataType.STRING,
676
+ },
695
677
  },
696
- },
678
+ });
679
+ const promise = S.getService(ModelDataValidator).validate('model', {
680
+ foo: [],
681
+ });
682
+ await expect(promise).to.be.rejectedWith(
683
+ 'The property "foo" of the model "model" must have ' +
684
+ 'a String, but Array given.',
685
+ );
697
686
  });
698
- const promise = S.getService(ModelDataValidator).validate('model', {
699
- foo: {},
687
+
688
+ it('throws an error if an object given', async function () {
689
+ const S = new Schema();
690
+ S.defineModel({
691
+ name: 'model',
692
+ datasource: 'datasource',
693
+ properties: {
694
+ foo: {
695
+ type: DataType.STRING,
696
+ },
697
+ },
698
+ });
699
+ const promise = S.getService(ModelDataValidator).validate('model', {
700
+ foo: {},
701
+ });
702
+ await expect(promise).to.be.rejectedWith(
703
+ 'The property "foo" of the model "model" must have ' +
704
+ 'a String, but Object given.',
705
+ );
700
706
  });
701
- await expect(promise).to.be.rejectedWith(
702
- 'The property "foo" of the model "model" must have ' +
703
- 'a String, but Object given.',
704
- );
705
707
  });
706
708
  });
707
- });
708
709
 
709
- describe('DataType.NUMBER', function () {
710
- describe('ShortPropertyDefinition', function () {
711
- it('does not throw an error if an undefined given', async function () {
712
- const S = new Schema();
713
- S.defineModel({
714
- name: 'model',
715
- datasource: 'datasource',
716
- properties: {
717
- foo: DataType.NUMBER,
718
- },
719
- });
720
- await S.getService(ModelDataValidator).validate('model', {
721
- foo: undefined,
710
+ describe('DataType.NUMBER', function () {
711
+ describe('ShortPropertyDefinition', function () {
712
+ it('does not throw an error if an undefined given', async function () {
713
+ const S = new Schema();
714
+ S.defineModel({
715
+ name: 'model',
716
+ datasource: 'datasource',
717
+ properties: {
718
+ foo: DataType.NUMBER,
719
+ },
720
+ });
721
+ await S.getService(ModelDataValidator).validate('model', {
722
+ foo: undefined,
723
+ });
722
724
  });
723
- });
724
725
 
725
- it('does not throw an error if a null given', async function () {
726
- const S = new Schema();
727
- S.defineModel({
728
- name: 'model',
729
- datasource: 'datasource',
730
- properties: {
731
- foo: DataType.NUMBER,
732
- },
733
- });
734
- await S.getService(ModelDataValidator).validate('model', {
735
- foo: null,
726
+ it('does not throw an error if a null given', async function () {
727
+ const S = new Schema();
728
+ S.defineModel({
729
+ name: 'model',
730
+ datasource: 'datasource',
731
+ properties: {
732
+ foo: DataType.NUMBER,
733
+ },
734
+ });
735
+ await S.getService(ModelDataValidator).validate('model', {
736
+ foo: null,
737
+ });
736
738
  });
737
- });
738
739
 
739
- it('throws an error if a string given', async function () {
740
- const S = new Schema();
741
- S.defineModel({
742
- name: 'model',
743
- datasource: 'datasource',
744
- properties: {
745
- foo: DataType.NUMBER,
746
- },
747
- });
748
- const promise = S.getService(ModelDataValidator).validate('model', {
749
- foo: 'bar',
740
+ it('throws an error if a string given', async function () {
741
+ const S = new Schema();
742
+ S.defineModel({
743
+ name: 'model',
744
+ datasource: 'datasource',
745
+ properties: {
746
+ foo: DataType.NUMBER,
747
+ },
748
+ });
749
+ const promise = S.getService(ModelDataValidator).validate('model', {
750
+ foo: 'bar',
751
+ });
752
+ await expect(promise).to.be.rejectedWith(
753
+ 'The property "foo" of the model "model" must have ' +
754
+ 'a Number, but String given.',
755
+ );
750
756
  });
751
- await expect(promise).to.be.rejectedWith(
752
- 'The property "foo" of the model "model" must have ' +
753
- 'a Number, but String given.',
754
- );
755
- });
756
757
 
757
- it('does not throw an error if a number given', async function () {
758
- const S = new Schema();
759
- S.defineModel({
760
- name: 'model',
761
- datasource: 'datasource',
762
- properties: {
763
- foo: DataType.NUMBER,
764
- },
765
- });
766
- await S.getService(ModelDataValidator).validate('model', {
767
- foo: 10,
758
+ it('does not throw an error if a number given', async function () {
759
+ const S = new Schema();
760
+ S.defineModel({
761
+ name: 'model',
762
+ datasource: 'datasource',
763
+ properties: {
764
+ foo: DataType.NUMBER,
765
+ },
766
+ });
767
+ await S.getService(ModelDataValidator).validate('model', {
768
+ foo: 10,
769
+ });
768
770
  });
769
- });
770
771
 
771
- it('throws an error if true given', async function () {
772
- const S = new Schema();
773
- S.defineModel({
774
- name: 'model',
775
- datasource: 'datasource',
776
- properties: {
777
- foo: DataType.NUMBER,
778
- },
779
- });
780
- const promise = S.getService(ModelDataValidator).validate('model', {
781
- foo: true,
772
+ it('throws an error if true given', async function () {
773
+ const S = new Schema();
774
+ S.defineModel({
775
+ name: 'model',
776
+ datasource: 'datasource',
777
+ properties: {
778
+ foo: DataType.NUMBER,
779
+ },
780
+ });
781
+ const promise = S.getService(ModelDataValidator).validate('model', {
782
+ foo: true,
783
+ });
784
+ await expect(promise).to.be.rejectedWith(
785
+ 'The property "foo" of the model "model" must have ' +
786
+ 'a Number, but Boolean given.',
787
+ );
782
788
  });
783
- await expect(promise).to.be.rejectedWith(
784
- 'The property "foo" of the model "model" must have ' +
785
- 'a Number, but Boolean given.',
786
- );
787
- });
788
789
 
789
- it('throws an error if false given', async function () {
790
- const S = new Schema();
791
- S.defineModel({
792
- name: 'model',
793
- datasource: 'datasource',
794
- properties: {
795
- foo: DataType.NUMBER,
796
- },
797
- });
798
- const promise = S.getService(ModelDataValidator).validate('model', {
799
- foo: false,
790
+ it('throws an error if false given', async function () {
791
+ const S = new Schema();
792
+ S.defineModel({
793
+ name: 'model',
794
+ datasource: 'datasource',
795
+ properties: {
796
+ foo: DataType.NUMBER,
797
+ },
798
+ });
799
+ const promise = S.getService(ModelDataValidator).validate('model', {
800
+ foo: false,
801
+ });
802
+ await expect(promise).to.be.rejectedWith(
803
+ 'The property "foo" of the model "model" must have ' +
804
+ 'a Number, but Boolean given.',
805
+ );
800
806
  });
801
- await expect(promise).to.be.rejectedWith(
802
- 'The property "foo" of the model "model" must have ' +
803
- 'a Number, but Boolean given.',
804
- );
805
- });
806
807
 
807
- it('throws an error if an array given', async function () {
808
- const S = new Schema();
809
- S.defineModel({
810
- name: 'model',
811
- datasource: 'datasource',
812
- properties: {
813
- foo: DataType.NUMBER,
814
- },
815
- });
816
- const promise = S.getService(ModelDataValidator).validate('model', {
817
- foo: [],
808
+ it('throws an error if an array given', async function () {
809
+ const S = new Schema();
810
+ S.defineModel({
811
+ name: 'model',
812
+ datasource: 'datasource',
813
+ properties: {
814
+ foo: DataType.NUMBER,
815
+ },
816
+ });
817
+ const promise = S.getService(ModelDataValidator).validate('model', {
818
+ foo: [],
819
+ });
820
+ await expect(promise).to.be.rejectedWith(
821
+ 'The property "foo" of the model "model" must have ' +
822
+ 'a Number, but Array given.',
823
+ );
818
824
  });
819
- await expect(promise).to.be.rejectedWith(
820
- 'The property "foo" of the model "model" must have ' +
821
- 'a Number, but Array given.',
822
- );
823
- });
824
825
 
825
- it('throws an error if an object given', async function () {
826
- const S = new Schema();
827
- S.defineModel({
828
- name: 'model',
829
- datasource: 'datasource',
830
- properties: {
831
- foo: DataType.NUMBER,
832
- },
833
- });
834
- const promise = S.getService(ModelDataValidator).validate('model', {
835
- foo: {},
826
+ it('throws an error if an object given', async function () {
827
+ const S = new Schema();
828
+ S.defineModel({
829
+ name: 'model',
830
+ datasource: 'datasource',
831
+ properties: {
832
+ foo: DataType.NUMBER,
833
+ },
834
+ });
835
+ const promise = S.getService(ModelDataValidator).validate('model', {
836
+ foo: {},
837
+ });
838
+ await expect(promise).to.be.rejectedWith(
839
+ 'The property "foo" of the model "model" must have ' +
840
+ 'a Number, but Object given.',
841
+ );
836
842
  });
837
- await expect(promise).to.be.rejectedWith(
838
- 'The property "foo" of the model "model" must have ' +
839
- 'a Number, but Object given.',
840
- );
841
843
  });
842
- });
843
844
 
844
- describe('FullPropertyDefinition', function () {
845
- it('does not throw an error if an undefined given', async function () {
846
- const S = new Schema();
847
- S.defineModel({
848
- name: 'model',
849
- datasource: 'datasource',
850
- properties: {
851
- foo: {
852
- type: DataType.NUMBER,
845
+ describe('FullPropertyDefinition', function () {
846
+ it('does not throw an error if an undefined given', async function () {
847
+ const S = new Schema();
848
+ S.defineModel({
849
+ name: 'model',
850
+ datasource: 'datasource',
851
+ properties: {
852
+ foo: {
853
+ type: DataType.NUMBER,
854
+ },
853
855
  },
854
- },
855
- });
856
- await S.getService(ModelDataValidator).validate('model', {
857
- foo: undefined,
856
+ });
857
+ await S.getService(ModelDataValidator).validate('model', {
858
+ foo: undefined,
859
+ });
858
860
  });
859
- });
860
861
 
861
- it('does not throw an error if a null given', async function () {
862
- const S = new Schema();
863
- S.defineModel({
864
- name: 'model',
865
- datasource: 'datasource',
866
- properties: {
867
- foo: {
868
- type: DataType.NUMBER,
862
+ it('does not throw an error if a null given', async function () {
863
+ const S = new Schema();
864
+ S.defineModel({
865
+ name: 'model',
866
+ datasource: 'datasource',
867
+ properties: {
868
+ foo: {
869
+ type: DataType.NUMBER,
870
+ },
869
871
  },
870
- },
871
- });
872
- await S.getService(ModelDataValidator).validate('model', {
873
- foo: null,
872
+ });
873
+ await S.getService(ModelDataValidator).validate('model', {
874
+ foo: null,
875
+ });
874
876
  });
875
- });
876
877
 
877
- it('throws an error if a string given', async function () {
878
- const S = new Schema();
879
- S.defineModel({
880
- name: 'model',
881
- datasource: 'datasource',
882
- properties: {
883
- foo: {
884
- type: DataType.NUMBER,
878
+ it('throws an error if a string given', async function () {
879
+ const S = new Schema();
880
+ S.defineModel({
881
+ name: 'model',
882
+ datasource: 'datasource',
883
+ properties: {
884
+ foo: {
885
+ type: DataType.NUMBER,
886
+ },
885
887
  },
886
- },
887
- });
888
- const promise = S.getService(ModelDataValidator).validate('model', {
889
- foo: 'bar',
888
+ });
889
+ const promise = S.getService(ModelDataValidator).validate('model', {
890
+ foo: 'bar',
891
+ });
892
+ await expect(promise).to.be.rejectedWith(
893
+ 'The property "foo" of the model "model" must have ' +
894
+ 'a Number, but String given.',
895
+ );
890
896
  });
891
- await expect(promise).to.be.rejectedWith(
892
- 'The property "foo" of the model "model" must have ' +
893
- 'a Number, but String given.',
894
- );
895
- });
896
897
 
897
- it('does not throw an error if a number given', async function () {
898
- const S = new Schema();
899
- S.defineModel({
900
- name: 'model',
901
- datasource: 'datasource',
902
- properties: {
903
- foo: {
904
- type: DataType.NUMBER,
898
+ it('does not throw an error if a number given', async function () {
899
+ const S = new Schema();
900
+ S.defineModel({
901
+ name: 'model',
902
+ datasource: 'datasource',
903
+ properties: {
904
+ foo: {
905
+ type: DataType.NUMBER,
906
+ },
905
907
  },
906
- },
907
- });
908
- await S.getService(ModelDataValidator).validate('model', {
909
- foo: 10,
908
+ });
909
+ await S.getService(ModelDataValidator).validate('model', {
910
+ foo: 10,
911
+ });
910
912
  });
911
- });
912
913
 
913
- it('throws an error if true given', async function () {
914
- const S = new Schema();
915
- S.defineModel({
916
- name: 'model',
917
- datasource: 'datasource',
918
- properties: {
919
- foo: {
920
- type: DataType.NUMBER,
914
+ it('throws an error if true given', async function () {
915
+ const S = new Schema();
916
+ S.defineModel({
917
+ name: 'model',
918
+ datasource: 'datasource',
919
+ properties: {
920
+ foo: {
921
+ type: DataType.NUMBER,
922
+ },
921
923
  },
922
- },
923
- });
924
- const promise = S.getService(ModelDataValidator).validate('model', {
925
- foo: true,
924
+ });
925
+ const promise = S.getService(ModelDataValidator).validate('model', {
926
+ foo: true,
927
+ });
928
+ await expect(promise).to.be.rejectedWith(
929
+ 'The property "foo" of the model "model" must have ' +
930
+ 'a Number, but Boolean given.',
931
+ );
926
932
  });
927
- await expect(promise).to.be.rejectedWith(
928
- 'The property "foo" of the model "model" must have ' +
929
- 'a Number, but Boolean given.',
930
- );
931
- });
932
933
 
933
- it('throws an error if false given', async function () {
934
- const S = new Schema();
935
- S.defineModel({
936
- name: 'model',
937
- datasource: 'datasource',
938
- properties: {
939
- foo: {
940
- type: DataType.NUMBER,
934
+ it('throws an error if false given', async function () {
935
+ const S = new Schema();
936
+ S.defineModel({
937
+ name: 'model',
938
+ datasource: 'datasource',
939
+ properties: {
940
+ foo: {
941
+ type: DataType.NUMBER,
942
+ },
941
943
  },
942
- },
943
- });
944
- const promise = S.getService(ModelDataValidator).validate('model', {
945
- foo: false,
944
+ });
945
+ const promise = S.getService(ModelDataValidator).validate('model', {
946
+ foo: false,
947
+ });
948
+ await expect(promise).to.be.rejectedWith(
949
+ 'The property "foo" of the model "model" must have ' +
950
+ 'a Number, but Boolean given.',
951
+ );
946
952
  });
947
- await expect(promise).to.be.rejectedWith(
948
- 'The property "foo" of the model "model" must have ' +
949
- 'a Number, but Boolean given.',
950
- );
951
- });
952
953
 
953
- it('throws an error if an array given', async function () {
954
- const S = new Schema();
955
- S.defineModel({
956
- name: 'model',
957
- datasource: 'datasource',
958
- properties: {
959
- foo: {
960
- type: DataType.NUMBER,
954
+ it('throws an error if an array given', async function () {
955
+ const S = new Schema();
956
+ S.defineModel({
957
+ name: 'model',
958
+ datasource: 'datasource',
959
+ properties: {
960
+ foo: {
961
+ type: DataType.NUMBER,
962
+ },
961
963
  },
962
- },
963
- });
964
- const promise = S.getService(ModelDataValidator).validate('model', {
965
- foo: [],
964
+ });
965
+ const promise = S.getService(ModelDataValidator).validate('model', {
966
+ foo: [],
967
+ });
968
+ await expect(promise).to.be.rejectedWith(
969
+ 'The property "foo" of the model "model" must have ' +
970
+ 'a Number, but Array given.',
971
+ );
966
972
  });
967
- await expect(promise).to.be.rejectedWith(
968
- 'The property "foo" of the model "model" must have ' +
969
- 'a Number, but Array given.',
970
- );
971
- });
972
973
 
973
- it('throws an error if an object given', async function () {
974
- const S = new Schema();
975
- S.defineModel({
976
- name: 'model',
977
- datasource: 'datasource',
978
- properties: {
979
- foo: {
980
- type: DataType.NUMBER,
974
+ it('throws an error if an object given', async function () {
975
+ const S = new Schema();
976
+ S.defineModel({
977
+ name: 'model',
978
+ datasource: 'datasource',
979
+ properties: {
980
+ foo: {
981
+ type: DataType.NUMBER,
982
+ },
981
983
  },
982
- },
983
- });
984
- const promise = S.getService(ModelDataValidator).validate('model', {
985
- foo: {},
984
+ });
985
+ const promise = S.getService(ModelDataValidator).validate('model', {
986
+ foo: {},
987
+ });
988
+ await expect(promise).to.be.rejectedWith(
989
+ 'The property "foo" of the model "model" must have ' +
990
+ 'a Number, but Object given.',
991
+ );
986
992
  });
987
- await expect(promise).to.be.rejectedWith(
988
- 'The property "foo" of the model "model" must have ' +
989
- 'a Number, but Object given.',
990
- );
991
993
  });
992
994
  });
993
- });
994
995
 
995
- describe('DataType.BOOLEAN', function () {
996
- describe('ShortPropertyDefinition', function () {
997
- it('does not throw an error if an undefined given', async function () {
998
- const S = new Schema();
999
- S.defineModel({
1000
- name: 'model',
1001
- datasource: 'datasource',
1002
- properties: {
1003
- foo: DataType.BOOLEAN,
1004
- },
1005
- });
1006
- await S.getService(ModelDataValidator).validate('model', {
1007
- foo: undefined,
996
+ describe('DataType.BOOLEAN', function () {
997
+ describe('ShortPropertyDefinition', function () {
998
+ it('does not throw an error if an undefined given', async function () {
999
+ const S = new Schema();
1000
+ S.defineModel({
1001
+ name: 'model',
1002
+ datasource: 'datasource',
1003
+ properties: {
1004
+ foo: DataType.BOOLEAN,
1005
+ },
1006
+ });
1007
+ await S.getService(ModelDataValidator).validate('model', {
1008
+ foo: undefined,
1009
+ });
1008
1010
  });
1009
- });
1010
1011
 
1011
- it('does not throw an error if a null given', async function () {
1012
- const S = new Schema();
1013
- S.defineModel({
1014
- name: 'model',
1015
- datasource: 'datasource',
1016
- properties: {
1017
- foo: DataType.BOOLEAN,
1018
- },
1019
- });
1020
- await S.getService(ModelDataValidator).validate('model', {
1021
- foo: null,
1012
+ it('does not throw an error if a null given', async function () {
1013
+ const S = new Schema();
1014
+ S.defineModel({
1015
+ name: 'model',
1016
+ datasource: 'datasource',
1017
+ properties: {
1018
+ foo: DataType.BOOLEAN,
1019
+ },
1020
+ });
1021
+ await S.getService(ModelDataValidator).validate('model', {
1022
+ foo: null,
1023
+ });
1022
1024
  });
1023
- });
1024
1025
 
1025
- it('throws an error if a string given', async function () {
1026
- const S = new Schema();
1027
- S.defineModel({
1028
- name: 'model',
1029
- datasource: 'datasource',
1030
- properties: {
1031
- foo: DataType.BOOLEAN,
1032
- },
1033
- });
1034
- const promise = S.getService(ModelDataValidator).validate('model', {
1035
- foo: 'bar',
1026
+ it('throws an error if a string given', async function () {
1027
+ const S = new Schema();
1028
+ S.defineModel({
1029
+ name: 'model',
1030
+ datasource: 'datasource',
1031
+ properties: {
1032
+ foo: DataType.BOOLEAN,
1033
+ },
1034
+ });
1035
+ const promise = S.getService(ModelDataValidator).validate('model', {
1036
+ foo: 'bar',
1037
+ });
1038
+ await expect(promise).to.be.rejectedWith(
1039
+ 'The property "foo" of the model "model" must have ' +
1040
+ 'a Boolean, but String given.',
1041
+ );
1036
1042
  });
1037
- await expect(promise).to.be.rejectedWith(
1038
- 'The property "foo" of the model "model" must have ' +
1039
- 'a Boolean, but String given.',
1040
- );
1041
- });
1042
1043
 
1043
- it('throws an error if a number given', async function () {
1044
- const S = new Schema();
1045
- S.defineModel({
1046
- name: 'model',
1047
- datasource: 'datasource',
1048
- properties: {
1049
- foo: DataType.BOOLEAN,
1050
- },
1051
- });
1052
- const promise = S.getService(ModelDataValidator).validate('model', {
1053
- foo: 10,
1044
+ it('throws an error if a number given', async function () {
1045
+ const S = new Schema();
1046
+ S.defineModel({
1047
+ name: 'model',
1048
+ datasource: 'datasource',
1049
+ properties: {
1050
+ foo: DataType.BOOLEAN,
1051
+ },
1052
+ });
1053
+ const promise = S.getService(ModelDataValidator).validate('model', {
1054
+ foo: 10,
1055
+ });
1056
+ await expect(promise).to.be.rejectedWith(
1057
+ 'The property "foo" of the model "model" must have ' +
1058
+ 'a Boolean, but Number given.',
1059
+ );
1054
1060
  });
1055
- await expect(promise).to.be.rejectedWith(
1056
- 'The property "foo" of the model "model" must have ' +
1057
- 'a Boolean, but Number given.',
1058
- );
1059
- });
1060
1061
 
1061
- it('does not throw an error if true given', async function () {
1062
- const S = new Schema();
1063
- S.defineModel({
1064
- name: 'model',
1065
- datasource: 'datasource',
1066
- properties: {
1067
- foo: DataType.BOOLEAN,
1068
- },
1069
- });
1070
- await S.getService(ModelDataValidator).validate('model', {
1071
- foo: true,
1062
+ it('does not throw an error if true given', async function () {
1063
+ const S = new Schema();
1064
+ S.defineModel({
1065
+ name: 'model',
1066
+ datasource: 'datasource',
1067
+ properties: {
1068
+ foo: DataType.BOOLEAN,
1069
+ },
1070
+ });
1071
+ await S.getService(ModelDataValidator).validate('model', {
1072
+ foo: true,
1073
+ });
1072
1074
  });
1073
- });
1074
1075
 
1075
- it('does not throw an error if false given', async function () {
1076
- const S = new Schema();
1077
- S.defineModel({
1078
- name: 'model',
1079
- datasource: 'datasource',
1080
- properties: {
1081
- foo: DataType.BOOLEAN,
1082
- },
1083
- });
1084
- await S.getService(ModelDataValidator).validate('model', {
1085
- foo: false,
1076
+ it('does not throw an error if false given', async function () {
1077
+ const S = new Schema();
1078
+ S.defineModel({
1079
+ name: 'model',
1080
+ datasource: 'datasource',
1081
+ properties: {
1082
+ foo: DataType.BOOLEAN,
1083
+ },
1084
+ });
1085
+ await S.getService(ModelDataValidator).validate('model', {
1086
+ foo: false,
1087
+ });
1086
1088
  });
1087
- });
1088
1089
 
1089
- it('throws an error if an array given', async function () {
1090
- const S = new Schema();
1091
- S.defineModel({
1092
- name: 'model',
1093
- datasource: 'datasource',
1094
- properties: {
1095
- foo: DataType.BOOLEAN,
1096
- },
1097
- });
1098
- const promise = S.getService(ModelDataValidator).validate('model', {
1099
- foo: [],
1090
+ it('throws an error if an array given', async function () {
1091
+ const S = new Schema();
1092
+ S.defineModel({
1093
+ name: 'model',
1094
+ datasource: 'datasource',
1095
+ properties: {
1096
+ foo: DataType.BOOLEAN,
1097
+ },
1098
+ });
1099
+ const promise = S.getService(ModelDataValidator).validate('model', {
1100
+ foo: [],
1101
+ });
1102
+ await expect(promise).to.be.rejectedWith(
1103
+ 'The property "foo" of the model "model" must have ' +
1104
+ 'a Boolean, but Array given.',
1105
+ );
1100
1106
  });
1101
- await expect(promise).to.be.rejectedWith(
1102
- 'The property "foo" of the model "model" must have ' +
1103
- 'a Boolean, but Array given.',
1104
- );
1105
- });
1106
1107
 
1107
- it('throws an error if an object given', async function () {
1108
- const S = new Schema();
1109
- S.defineModel({
1110
- name: 'model',
1111
- datasource: 'datasource',
1112
- properties: {
1113
- foo: DataType.BOOLEAN,
1114
- },
1115
- });
1116
- const promise = S.getService(ModelDataValidator).validate('model', {
1117
- foo: {},
1108
+ it('throws an error if an object given', async function () {
1109
+ const S = new Schema();
1110
+ S.defineModel({
1111
+ name: 'model',
1112
+ datasource: 'datasource',
1113
+ properties: {
1114
+ foo: DataType.BOOLEAN,
1115
+ },
1116
+ });
1117
+ const promise = S.getService(ModelDataValidator).validate('model', {
1118
+ foo: {},
1119
+ });
1120
+ await expect(promise).to.be.rejectedWith(
1121
+ 'The property "foo" of the model "model" must have ' +
1122
+ 'a Boolean, but Object given.',
1123
+ );
1118
1124
  });
1119
- await expect(promise).to.be.rejectedWith(
1120
- 'The property "foo" of the model "model" must have ' +
1121
- 'a Boolean, but Object given.',
1122
- );
1123
1125
  });
1124
- });
1125
1126
 
1126
- describe('FullPropertyDefinition', function () {
1127
- it('does not throw an error if an undefined given', async function () {
1128
- const S = new Schema();
1129
- S.defineModel({
1130
- name: 'model',
1131
- datasource: 'datasource',
1132
- properties: {
1133
- foo: {
1134
- type: DataType.BOOLEAN,
1127
+ describe('FullPropertyDefinition', function () {
1128
+ it('does not throw an error if an undefined given', async function () {
1129
+ const S = new Schema();
1130
+ S.defineModel({
1131
+ name: 'model',
1132
+ datasource: 'datasource',
1133
+ properties: {
1134
+ foo: {
1135
+ type: DataType.BOOLEAN,
1136
+ },
1135
1137
  },
1136
- },
1137
- });
1138
- await S.getService(ModelDataValidator).validate('model', {
1139
- foo: undefined,
1138
+ });
1139
+ await S.getService(ModelDataValidator).validate('model', {
1140
+ foo: undefined,
1141
+ });
1140
1142
  });
1141
- });
1142
1143
 
1143
- it('does not throw an error if a null given', async function () {
1144
- const S = new Schema();
1145
- S.defineModel({
1146
- name: 'model',
1147
- datasource: 'datasource',
1148
- properties: {
1149
- foo: {
1150
- type: DataType.BOOLEAN,
1144
+ it('does not throw an error if a null given', async function () {
1145
+ const S = new Schema();
1146
+ S.defineModel({
1147
+ name: 'model',
1148
+ datasource: 'datasource',
1149
+ properties: {
1150
+ foo: {
1151
+ type: DataType.BOOLEAN,
1152
+ },
1151
1153
  },
1152
- },
1153
- });
1154
- await S.getService(ModelDataValidator).validate('model', {
1155
- foo: null,
1154
+ });
1155
+ await S.getService(ModelDataValidator).validate('model', {
1156
+ foo: null,
1157
+ });
1156
1158
  });
1157
- });
1158
1159
 
1159
- it('throws an error if a string given', async function () {
1160
- const S = new Schema();
1161
- S.defineModel({
1162
- name: 'model',
1163
- datasource: 'datasource',
1164
- properties: {
1165
- foo: {
1166
- type: DataType.BOOLEAN,
1160
+ it('throws an error if a string given', async function () {
1161
+ const S = new Schema();
1162
+ S.defineModel({
1163
+ name: 'model',
1164
+ datasource: 'datasource',
1165
+ properties: {
1166
+ foo: {
1167
+ type: DataType.BOOLEAN,
1168
+ },
1167
1169
  },
1168
- },
1169
- });
1170
- const promise = S.getService(ModelDataValidator).validate('model', {
1171
- foo: 'bar',
1170
+ });
1171
+ const promise = S.getService(ModelDataValidator).validate('model', {
1172
+ foo: 'bar',
1173
+ });
1174
+ await expect(promise).to.be.rejectedWith(
1175
+ 'The property "foo" of the model "model" must have ' +
1176
+ 'a Boolean, but String given.',
1177
+ );
1172
1178
  });
1173
- await expect(promise).to.be.rejectedWith(
1174
- 'The property "foo" of the model "model" must have ' +
1175
- 'a Boolean, but String given.',
1176
- );
1177
- });
1178
1179
 
1179
- it('throws an error if a number given', async function () {
1180
- const S = new Schema();
1181
- S.defineModel({
1182
- name: 'model',
1183
- datasource: 'datasource',
1184
- properties: {
1185
- foo: {
1186
- type: DataType.BOOLEAN,
1180
+ it('throws an error if a number given', async function () {
1181
+ const S = new Schema();
1182
+ S.defineModel({
1183
+ name: 'model',
1184
+ datasource: 'datasource',
1185
+ properties: {
1186
+ foo: {
1187
+ type: DataType.BOOLEAN,
1188
+ },
1187
1189
  },
1188
- },
1189
- });
1190
- const promise = S.getService(ModelDataValidator).validate('model', {
1191
- foo: 10,
1190
+ });
1191
+ const promise = S.getService(ModelDataValidator).validate('model', {
1192
+ foo: 10,
1193
+ });
1194
+ await expect(promise).to.be.rejectedWith(
1195
+ 'The property "foo" of the model "model" must have ' +
1196
+ 'a Boolean, but Number given.',
1197
+ );
1192
1198
  });
1193
- await expect(promise).to.be.rejectedWith(
1194
- 'The property "foo" of the model "model" must have ' +
1195
- 'a Boolean, but Number given.',
1196
- );
1197
- });
1198
1199
 
1199
- it('does not throw an error if true given', async function () {
1200
- const S = new Schema();
1201
- S.defineModel({
1202
- name: 'model',
1203
- datasource: 'datasource',
1204
- properties: {
1205
- foo: {
1206
- type: DataType.BOOLEAN,
1200
+ it('does not throw an error if true given', async function () {
1201
+ const S = new Schema();
1202
+ S.defineModel({
1203
+ name: 'model',
1204
+ datasource: 'datasource',
1205
+ properties: {
1206
+ foo: {
1207
+ type: DataType.BOOLEAN,
1208
+ },
1207
1209
  },
1208
- },
1209
- });
1210
- await S.getService(ModelDataValidator).validate('model', {
1211
- foo: true,
1210
+ });
1211
+ await S.getService(ModelDataValidator).validate('model', {
1212
+ foo: true,
1213
+ });
1212
1214
  });
1213
- });
1214
1215
 
1215
- it('does not throw an error if false given', async function () {
1216
- const S = new Schema();
1217
- S.defineModel({
1218
- name: 'model',
1219
- datasource: 'datasource',
1220
- properties: {
1221
- foo: {
1222
- type: DataType.BOOLEAN,
1216
+ it('does not throw an error if false given', async function () {
1217
+ const S = new Schema();
1218
+ S.defineModel({
1219
+ name: 'model',
1220
+ datasource: 'datasource',
1221
+ properties: {
1222
+ foo: {
1223
+ type: DataType.BOOLEAN,
1224
+ },
1223
1225
  },
1224
- },
1225
- });
1226
- await S.getService(ModelDataValidator).validate('model', {
1227
- foo: false,
1226
+ });
1227
+ await S.getService(ModelDataValidator).validate('model', {
1228
+ foo: false,
1229
+ });
1228
1230
  });
1229
- });
1230
1231
 
1231
- it('throws an error if an array given', async function () {
1232
- const S = new Schema();
1233
- S.defineModel({
1234
- name: 'model',
1235
- datasource: 'datasource',
1236
- properties: {
1237
- foo: {
1238
- type: DataType.BOOLEAN,
1232
+ it('throws an error if an array given', async function () {
1233
+ const S = new Schema();
1234
+ S.defineModel({
1235
+ name: 'model',
1236
+ datasource: 'datasource',
1237
+ properties: {
1238
+ foo: {
1239
+ type: DataType.BOOLEAN,
1240
+ },
1239
1241
  },
1240
- },
1241
- });
1242
- const promise = S.getService(ModelDataValidator).validate('model', {
1243
- foo: [],
1242
+ });
1243
+ const promise = S.getService(ModelDataValidator).validate('model', {
1244
+ foo: [],
1245
+ });
1246
+ await expect(promise).to.be.rejectedWith(
1247
+ 'The property "foo" of the model "model" must have ' +
1248
+ 'a Boolean, but Array given.',
1249
+ );
1244
1250
  });
1245
- await expect(promise).to.be.rejectedWith(
1246
- 'The property "foo" of the model "model" must have ' +
1247
- 'a Boolean, but Array given.',
1248
- );
1249
- });
1250
1251
 
1251
- it('throws an error if an object given', async function () {
1252
- const S = new Schema();
1253
- S.defineModel({
1254
- name: 'model',
1255
- datasource: 'datasource',
1256
- properties: {
1257
- foo: {
1258
- type: DataType.BOOLEAN,
1252
+ it('throws an error if an object given', async function () {
1253
+ const S = new Schema();
1254
+ S.defineModel({
1255
+ name: 'model',
1256
+ datasource: 'datasource',
1257
+ properties: {
1258
+ foo: {
1259
+ type: DataType.BOOLEAN,
1260
+ },
1259
1261
  },
1260
- },
1261
- });
1262
- const promise = S.getService(ModelDataValidator).validate('model', {
1263
- foo: {},
1262
+ });
1263
+ const promise = S.getService(ModelDataValidator).validate('model', {
1264
+ foo: {},
1265
+ });
1266
+ await expect(promise).to.be.rejectedWith(
1267
+ 'The property "foo" of the model "model" must have ' +
1268
+ 'a Boolean, but Object given.',
1269
+ );
1264
1270
  });
1265
- await expect(promise).to.be.rejectedWith(
1266
- 'The property "foo" of the model "model" must have ' +
1267
- 'a Boolean, but Object given.',
1268
- );
1269
1271
  });
1270
1272
  });
1271
- });
1272
1273
 
1273
- describe('DataType.ARRAY', function () {
1274
- describe('ShortPropertyDefinition', function () {
1275
- it('does not throw an error if an undefined given', async function () {
1276
- const S = new Schema();
1277
- S.defineModel({
1278
- name: 'model',
1279
- datasource: 'datasource',
1280
- properties: {
1281
- foo: DataType.ARRAY,
1282
- },
1283
- });
1284
- await S.getService(ModelDataValidator).validate('model', {
1285
- foo: undefined,
1286
- });
1287
- });
1288
-
1289
- it('does not throw an error if a null given', async function () {
1290
- const S = new Schema();
1291
- S.defineModel({
1292
- name: 'model',
1293
- datasource: 'datasource',
1294
- properties: {
1295
- foo: DataType.ARRAY,
1296
- },
1297
- });
1298
- await S.getService(ModelDataValidator).validate('model', {
1299
- foo: null,
1300
- });
1301
- });
1302
-
1303
- it('throws an error if a string given', async function () {
1304
- const S = new Schema();
1305
- S.defineModel({
1306
- name: 'model',
1307
- datasource: 'datasource',
1308
- properties: {
1309
- foo: DataType.ARRAY,
1310
- },
1311
- });
1312
- const promise = S.getService(ModelDataValidator).validate('model', {
1313
- foo: 'bar',
1314
- });
1315
- await expect(promise).to.be.rejectedWith(
1316
- 'The property "foo" of the model "model" must have ' +
1317
- 'an Array, but String given.',
1318
- );
1319
- });
1320
-
1321
- it('throws an error if a number given', async function () {
1322
- const S = new Schema();
1323
- S.defineModel({
1324
- name: 'model',
1325
- datasource: 'datasource',
1326
- properties: {
1327
- foo: DataType.ARRAY,
1328
- },
1329
- });
1330
- const promise = S.getService(ModelDataValidator).validate('model', {
1331
- foo: 10,
1332
- });
1333
- await expect(promise).to.be.rejectedWith(
1334
- 'The property "foo" of the model "model" must have ' +
1335
- 'an Array, but Number given.',
1336
- );
1337
- });
1338
-
1339
- it('throws an error if true given', async function () {
1340
- const S = new Schema();
1341
- S.defineModel({
1342
- name: 'model',
1343
- datasource: 'datasource',
1344
- properties: {
1345
- foo: DataType.ARRAY,
1346
- },
1347
- });
1348
- const promise = S.getService(ModelDataValidator).validate('model', {
1349
- foo: true,
1350
- });
1351
- await expect(promise).to.be.rejectedWith(
1352
- 'The property "foo" of the model "model" must have ' +
1353
- 'an Array, but Boolean given.',
1354
- );
1355
- });
1356
-
1357
- it('throws an error if false given', async function () {
1358
- const S = new Schema();
1359
- S.defineModel({
1360
- name: 'model',
1361
- datasource: 'datasource',
1362
- properties: {
1363
- foo: DataType.ARRAY,
1364
- },
1365
- });
1366
- const promise = S.getService(ModelDataValidator).validate('model', {
1367
- foo: false,
1368
- });
1369
- await expect(promise).to.be.rejectedWith(
1370
- 'The property "foo" of the model "model" must have ' +
1371
- 'an Array, but Boolean given.',
1372
- );
1373
- });
1374
-
1375
- it('does not throw an error if an array given', async function () {
1376
- const S = new Schema();
1377
- S.defineModel({
1378
- name: 'model',
1379
- datasource: 'datasource',
1380
- properties: {
1381
- foo: DataType.ARRAY,
1382
- },
1383
- });
1384
- await S.getService(ModelDataValidator).validate('model', {
1385
- foo: [],
1274
+ describe('DataType.ARRAY', function () {
1275
+ describe('ShortPropertyDefinition', function () {
1276
+ it('does not throw an error if an undefined given', async function () {
1277
+ const S = new Schema();
1278
+ S.defineModel({
1279
+ name: 'model',
1280
+ datasource: 'datasource',
1281
+ properties: {
1282
+ foo: DataType.ARRAY,
1283
+ },
1284
+ });
1285
+ await S.getService(ModelDataValidator).validate('model', {
1286
+ foo: undefined,
1287
+ });
1386
1288
  });
1387
- });
1388
1289
 
1389
- it('throws an error if an object given', async function () {
1390
- const S = new Schema();
1391
- S.defineModel({
1392
- name: 'model',
1393
- datasource: 'datasource',
1394
- properties: {
1395
- foo: DataType.ARRAY,
1396
- },
1397
- });
1398
- const promise = S.getService(ModelDataValidator).validate('model', {
1399
- foo: {},
1290
+ it('does not throw an error if a null given', async function () {
1291
+ const S = new Schema();
1292
+ S.defineModel({
1293
+ name: 'model',
1294
+ datasource: 'datasource',
1295
+ properties: {
1296
+ foo: DataType.ARRAY,
1297
+ },
1298
+ });
1299
+ await S.getService(ModelDataValidator).validate('model', {
1300
+ foo: null,
1301
+ });
1400
1302
  });
1401
- await expect(promise).to.be.rejectedWith(
1402
- 'The property "foo" of the model "model" must have ' +
1403
- 'an Array, but Object given.',
1404
- );
1405
- });
1406
- });
1407
1303
 
1408
- describe('FullPropertyDefinition', function () {
1409
- it('does not throw an error if an undefined given', async function () {
1410
- const S = new Schema();
1411
- S.defineModel({
1412
- name: 'model',
1413
- datasource: 'datasource',
1414
- properties: {
1415
- foo: {
1416
- type: DataType.ARRAY,
1304
+ it('throws an error if a string given', async function () {
1305
+ const S = new Schema();
1306
+ S.defineModel({
1307
+ name: 'model',
1308
+ datasource: 'datasource',
1309
+ properties: {
1310
+ foo: DataType.ARRAY,
1417
1311
  },
1418
- },
1419
- });
1420
- await S.getService(ModelDataValidator).validate('model', {
1421
- foo: undefined,
1312
+ });
1313
+ const promise = S.getService(ModelDataValidator).validate('model', {
1314
+ foo: 'bar',
1315
+ });
1316
+ await expect(promise).to.be.rejectedWith(
1317
+ 'The property "foo" of the model "model" must have ' +
1318
+ 'an Array, but String given.',
1319
+ );
1422
1320
  });
1423
- });
1424
1321
 
1425
- it('does not throw an error if a null given', async function () {
1426
- const S = new Schema();
1427
- S.defineModel({
1428
- name: 'model',
1429
- datasource: 'datasource',
1430
- properties: {
1431
- foo: {
1432
- type: DataType.ARRAY,
1322
+ it('throws an error if a number given', async function () {
1323
+ const S = new Schema();
1324
+ S.defineModel({
1325
+ name: 'model',
1326
+ datasource: 'datasource',
1327
+ properties: {
1328
+ foo: DataType.ARRAY,
1433
1329
  },
1434
- },
1435
- });
1436
- await S.getService(ModelDataValidator).validate('model', {
1437
- foo: null,
1330
+ });
1331
+ const promise = S.getService(ModelDataValidator).validate('model', {
1332
+ foo: 10,
1333
+ });
1334
+ await expect(promise).to.be.rejectedWith(
1335
+ 'The property "foo" of the model "model" must have ' +
1336
+ 'an Array, but Number given.',
1337
+ );
1438
1338
  });
1439
- });
1440
1339
 
1441
- it('throws an error if a string given', async function () {
1442
- const S = new Schema();
1443
- S.defineModel({
1444
- name: 'model',
1445
- datasource: 'datasource',
1446
- properties: {
1447
- foo: {
1448
- type: DataType.ARRAY,
1340
+ it('throws an error if true given', async function () {
1341
+ const S = new Schema();
1342
+ S.defineModel({
1343
+ name: 'model',
1344
+ datasource: 'datasource',
1345
+ properties: {
1346
+ foo: DataType.ARRAY,
1449
1347
  },
1450
- },
1451
- });
1452
- const promise = S.getService(ModelDataValidator).validate('model', {
1453
- foo: 'bar',
1348
+ });
1349
+ const promise = S.getService(ModelDataValidator).validate('model', {
1350
+ foo: true,
1351
+ });
1352
+ await expect(promise).to.be.rejectedWith(
1353
+ 'The property "foo" of the model "model" must have ' +
1354
+ 'an Array, but Boolean given.',
1355
+ );
1454
1356
  });
1455
- await expect(promise).to.be.rejectedWith(
1456
- 'The property "foo" of the model "model" must have ' +
1457
- 'an Array, but String given.',
1458
- );
1459
- });
1460
1357
 
1461
- it('throws an error if a number given', async function () {
1462
- const S = new Schema();
1463
- S.defineModel({
1464
- name: 'model',
1465
- datasource: 'datasource',
1466
- properties: {
1467
- foo: {
1468
- type: DataType.ARRAY,
1358
+ it('throws an error if false given', async function () {
1359
+ const S = new Schema();
1360
+ S.defineModel({
1361
+ name: 'model',
1362
+ datasource: 'datasource',
1363
+ properties: {
1364
+ foo: DataType.ARRAY,
1469
1365
  },
1470
- },
1471
- });
1472
- const promise = S.getService(ModelDataValidator).validate('model', {
1473
- foo: 10,
1366
+ });
1367
+ const promise = S.getService(ModelDataValidator).validate('model', {
1368
+ foo: false,
1369
+ });
1370
+ await expect(promise).to.be.rejectedWith(
1371
+ 'The property "foo" of the model "model" must have ' +
1372
+ 'an Array, but Boolean given.',
1373
+ );
1474
1374
  });
1475
- await expect(promise).to.be.rejectedWith(
1476
- 'The property "foo" of the model "model" must have ' +
1477
- 'an Array, but Number given.',
1478
- );
1479
- });
1480
1375
 
1481
- it('throws an error if true given', async function () {
1482
- const S = new Schema();
1483
- S.defineModel({
1484
- name: 'model',
1485
- datasource: 'datasource',
1486
- properties: {
1487
- foo: {
1488
- type: DataType.ARRAY,
1376
+ it('does not throw an error if an array given', async function () {
1377
+ const S = new Schema();
1378
+ S.defineModel({
1379
+ name: 'model',
1380
+ datasource: 'datasource',
1381
+ properties: {
1382
+ foo: DataType.ARRAY,
1489
1383
  },
1490
- },
1491
- });
1492
- const promise = S.getService(ModelDataValidator).validate('model', {
1493
- foo: true,
1384
+ });
1385
+ await S.getService(ModelDataValidator).validate('model', {
1386
+ foo: [],
1387
+ });
1494
1388
  });
1495
- await expect(promise).to.be.rejectedWith(
1496
- 'The property "foo" of the model "model" must have ' +
1497
- 'an Array, but Boolean given.',
1498
- );
1499
- });
1500
1389
 
1501
- it('throws an error if false given', async function () {
1502
- const S = new Schema();
1503
- S.defineModel({
1504
- name: 'model',
1505
- datasource: 'datasource',
1506
- properties: {
1507
- foo: {
1508
- type: DataType.ARRAY,
1390
+ it('throws an error if an object given', async function () {
1391
+ const S = new Schema();
1392
+ S.defineModel({
1393
+ name: 'model',
1394
+ datasource: 'datasource',
1395
+ properties: {
1396
+ foo: DataType.ARRAY,
1509
1397
  },
1510
- },
1511
- });
1512
- const promise = S.getService(ModelDataValidator).validate('model', {
1513
- foo: false,
1398
+ });
1399
+ const promise = S.getService(ModelDataValidator).validate('model', {
1400
+ foo: {},
1401
+ });
1402
+ await expect(promise).to.be.rejectedWith(
1403
+ 'The property "foo" of the model "model" must have ' +
1404
+ 'an Array, but Object given.',
1405
+ );
1514
1406
  });
1515
- await expect(promise).to.be.rejectedWith(
1516
- 'The property "foo" of the model "model" must have ' +
1517
- 'an Array, but Boolean given.',
1518
- );
1519
1407
  });
1520
1408
 
1521
- it('does not throw an error if an array given', async function () {
1522
- const S = new Schema();
1523
- S.defineModel({
1524
- name: 'model',
1525
- datasource: 'datasource',
1526
- properties: {
1527
- foo: {
1528
- type: DataType.ARRAY,
1409
+ describe('FullPropertyDefinition', function () {
1410
+ it('does not throw an error if an undefined given', async function () {
1411
+ const S = new Schema();
1412
+ S.defineModel({
1413
+ name: 'model',
1414
+ datasource: 'datasource',
1415
+ properties: {
1416
+ foo: {
1417
+ type: DataType.ARRAY,
1418
+ },
1529
1419
  },
1530
- },
1531
- });
1532
- await S.getService(ModelDataValidator).validate('model', {
1533
- foo: [],
1420
+ });
1421
+ await S.getService(ModelDataValidator).validate('model', {
1422
+ foo: undefined,
1423
+ });
1534
1424
  });
1535
- });
1536
1425
 
1537
- it('throws an error if an object given', async function () {
1538
- const S = new Schema();
1539
- S.defineModel({
1540
- name: 'model',
1541
- datasource: 'datasource',
1542
- properties: {
1543
- foo: {
1544
- type: DataType.ARRAY,
1426
+ it('does not throw an error if a null given', async function () {
1427
+ const S = new Schema();
1428
+ S.defineModel({
1429
+ name: 'model',
1430
+ datasource: 'datasource',
1431
+ properties: {
1432
+ foo: {
1433
+ type: DataType.ARRAY,
1434
+ },
1545
1435
  },
1546
- },
1547
- });
1548
- const promise = S.getService(ModelDataValidator).validate('model', {
1549
- foo: {},
1436
+ });
1437
+ await S.getService(ModelDataValidator).validate('model', {
1438
+ foo: null,
1439
+ });
1550
1440
  });
1551
- await expect(promise).to.be.rejectedWith(
1552
- 'The property "foo" of the model "model" must have ' +
1553
- 'an Array, but Object given.',
1554
- );
1555
- });
1556
1441
 
1557
- describe('the "model" option', function () {
1558
- it('throws an error when the given object element has an invalid model', async function () {
1442
+ it('throws an error if a string given', async function () {
1559
1443
  const S = new Schema();
1560
1444
  S.defineModel({
1561
- name: 'modelA',
1445
+ name: 'model',
1446
+ datasource: 'datasource',
1562
1447
  properties: {
1563
- foo: DataType.STRING,
1448
+ foo: {
1449
+ type: DataType.ARRAY,
1450
+ },
1564
1451
  },
1565
1452
  });
1453
+ const promise = S.getService(ModelDataValidator).validate('model', {
1454
+ foo: 'bar',
1455
+ });
1456
+ await expect(promise).to.be.rejectedWith(
1457
+ 'The property "foo" of the model "model" must have ' +
1458
+ 'an Array, but String given.',
1459
+ );
1460
+ });
1461
+
1462
+ it('throws an error if a number given', async function () {
1463
+ const S = new Schema();
1566
1464
  S.defineModel({
1567
- name: 'modelB',
1465
+ name: 'model',
1568
1466
  datasource: 'datasource',
1569
1467
  properties: {
1570
- bar: {
1468
+ foo: {
1571
1469
  type: DataType.ARRAY,
1572
- itemType: DataType.OBJECT,
1573
- model: 'modelA',
1574
1470
  },
1575
1471
  },
1576
1472
  });
1577
- const promise = S.getService(ModelDataValidator).validate(
1578
- 'modelB',
1579
- {
1580
- bar: [{foo: 10}],
1581
- },
1582
- );
1473
+ const promise = S.getService(ModelDataValidator).validate('model', {
1474
+ foo: 10,
1475
+ });
1583
1476
  await expect(promise).to.be.rejectedWith(
1584
- 'The property "foo" of the model "modelA" must have ' +
1585
- 'a String, but Number given.',
1477
+ 'The property "foo" of the model "model" must have ' +
1478
+ 'an Array, but Number given.',
1586
1479
  );
1587
1480
  });
1588
1481
 
1589
- it('does not throw an error when the given object element has a valid model', async function () {
1482
+ it('throws an error if true given', async function () {
1590
1483
  const S = new Schema();
1591
1484
  S.defineModel({
1592
- name: 'modelA',
1485
+ name: 'model',
1486
+ datasource: 'datasource',
1593
1487
  properties: {
1594
- foo: DataType.STRING,
1488
+ foo: {
1489
+ type: DataType.ARRAY,
1490
+ },
1595
1491
  },
1596
1492
  });
1493
+ const promise = S.getService(ModelDataValidator).validate('model', {
1494
+ foo: true,
1495
+ });
1496
+ await expect(promise).to.be.rejectedWith(
1497
+ 'The property "foo" of the model "model" must have ' +
1498
+ 'an Array, but Boolean given.',
1499
+ );
1500
+ });
1501
+
1502
+ it('throws an error if false given', async function () {
1503
+ const S = new Schema();
1597
1504
  S.defineModel({
1598
- name: 'modelB',
1505
+ name: 'model',
1599
1506
  datasource: 'datasource',
1600
1507
  properties: {
1601
- bar: {
1508
+ foo: {
1602
1509
  type: DataType.ARRAY,
1603
- itemType: DataType.OBJECT,
1604
- model: 'modelA',
1605
1510
  },
1606
1511
  },
1607
1512
  });
1608
- await S.getService(ModelDataValidator).validate('modelB', {
1609
- bar: [{foo: '10'}],
1513
+ const promise = S.getService(ModelDataValidator).validate('model', {
1514
+ foo: false,
1610
1515
  });
1516
+ await expect(promise).to.be.rejectedWith(
1517
+ 'The property "foo" of the model "model" must have ' +
1518
+ 'an Array, but Boolean given.',
1519
+ );
1611
1520
  });
1612
- });
1613
- });
1614
- });
1615
1521
 
1616
- describe('DataType.OBJECT', function () {
1617
- describe('ShortPropertyDefinition', function () {
1618
- it('does not throw an error if an undefined given', async function () {
1619
- const S = new Schema();
1620
- S.defineModel({
1621
- name: 'model',
1622
- datasource: 'datasource',
1623
- properties: {
1624
- foo: DataType.OBJECT,
1625
- },
1626
- });
1627
- await S.getService(ModelDataValidator).validate('model', {
1628
- foo: undefined,
1522
+ it('does not throw an error if an array given', async function () {
1523
+ const S = new Schema();
1524
+ S.defineModel({
1525
+ name: 'model',
1526
+ datasource: 'datasource',
1527
+ properties: {
1528
+ foo: {
1529
+ type: DataType.ARRAY,
1530
+ },
1531
+ },
1532
+ });
1533
+ await S.getService(ModelDataValidator).validate('model', {
1534
+ foo: [],
1535
+ });
1629
1536
  });
1630
- });
1631
1537
 
1632
- it('does not throw an error if a null given', async function () {
1633
- const S = new Schema();
1634
- S.defineModel({
1635
- name: 'model',
1636
- datasource: 'datasource',
1637
- properties: {
1638
- foo: DataType.OBJECT,
1639
- },
1640
- });
1641
- await S.getService(ModelDataValidator).validate('model', {
1642
- foo: null,
1538
+ it('throws an error if an object given', async function () {
1539
+ const S = new Schema();
1540
+ S.defineModel({
1541
+ name: 'model',
1542
+ datasource: 'datasource',
1543
+ properties: {
1544
+ foo: {
1545
+ type: DataType.ARRAY,
1546
+ },
1547
+ },
1548
+ });
1549
+ const promise = S.getService(ModelDataValidator).validate('model', {
1550
+ foo: {},
1551
+ });
1552
+ await expect(promise).to.be.rejectedWith(
1553
+ 'The property "foo" of the model "model" must have ' +
1554
+ 'an Array, but Object given.',
1555
+ );
1643
1556
  });
1644
- });
1645
1557
 
1646
- it('throws an error if a string given', async function () {
1647
- const S = new Schema();
1648
- S.defineModel({
1649
- name: 'model',
1650
- datasource: 'datasource',
1651
- properties: {
1652
- foo: DataType.OBJECT,
1653
- },
1654
- });
1655
- const promise = S.getService(ModelDataValidator).validate('model', {
1656
- foo: 'bar',
1657
- });
1658
- await expect(promise).to.be.rejectedWith(
1659
- 'The property "foo" of the model "model" must have ' +
1660
- 'an Object, but String given.',
1661
- );
1662
- });
1558
+ describe('the "model" option', function () {
1559
+ it('throws an error when the given object element has an invalid model', async function () {
1560
+ const S = new Schema();
1561
+ S.defineModel({
1562
+ name: 'modelA',
1563
+ properties: {
1564
+ foo: DataType.STRING,
1565
+ },
1566
+ });
1567
+ S.defineModel({
1568
+ name: 'modelB',
1569
+ datasource: 'datasource',
1570
+ properties: {
1571
+ bar: {
1572
+ type: DataType.ARRAY,
1573
+ itemType: DataType.OBJECT,
1574
+ model: 'modelA',
1575
+ },
1576
+ },
1577
+ });
1578
+ const promise = S.getService(ModelDataValidator).validate(
1579
+ 'modelB',
1580
+ {
1581
+ bar: [{foo: 10}],
1582
+ },
1583
+ );
1584
+ await expect(promise).to.be.rejectedWith(
1585
+ 'The property "foo" of the model "modelA" must have ' +
1586
+ 'a String, but Number given.',
1587
+ );
1588
+ });
1663
1589
 
1664
- it('throws an error if a number given', async function () {
1665
- const S = new Schema();
1666
- S.defineModel({
1667
- name: 'model',
1668
- datasource: 'datasource',
1669
- properties: {
1670
- foo: DataType.OBJECT,
1671
- },
1672
- });
1673
- const promise = S.getService(ModelDataValidator).validate('model', {
1674
- foo: 10,
1590
+ it('does not throw an error when the given object element has a valid model', async function () {
1591
+ const S = new Schema();
1592
+ S.defineModel({
1593
+ name: 'modelA',
1594
+ properties: {
1595
+ foo: DataType.STRING,
1596
+ },
1597
+ });
1598
+ S.defineModel({
1599
+ name: 'modelB',
1600
+ datasource: 'datasource',
1601
+ properties: {
1602
+ bar: {
1603
+ type: DataType.ARRAY,
1604
+ itemType: DataType.OBJECT,
1605
+ model: 'modelA',
1606
+ },
1607
+ },
1608
+ });
1609
+ await S.getService(ModelDataValidator).validate('modelB', {
1610
+ bar: [{foo: '10'}],
1611
+ });
1612
+ });
1675
1613
  });
1676
- await expect(promise).to.be.rejectedWith(
1677
- 'The property "foo" of the model "model" must have ' +
1678
- 'an Object, but Number given.',
1679
- );
1680
1614
  });
1615
+ });
1681
1616
 
1682
- it('throws an error if true given', async function () {
1683
- const S = new Schema();
1684
- S.defineModel({
1685
- name: 'model',
1686
- datasource: 'datasource',
1687
- properties: {
1688
- foo: DataType.OBJECT,
1689
- },
1690
- });
1691
- const promise = S.getService(ModelDataValidator).validate('model', {
1692
- foo: true,
1617
+ describe('DataType.OBJECT', function () {
1618
+ describe('ShortPropertyDefinition', function () {
1619
+ it('does not throw an error if an undefined given', async function () {
1620
+ const S = new Schema();
1621
+ S.defineModel({
1622
+ name: 'model',
1623
+ datasource: 'datasource',
1624
+ properties: {
1625
+ foo: DataType.OBJECT,
1626
+ },
1627
+ });
1628
+ await S.getService(ModelDataValidator).validate('model', {
1629
+ foo: undefined,
1630
+ });
1693
1631
  });
1694
- await expect(promise).to.be.rejectedWith(
1695
- 'The property "foo" of the model "model" must have ' +
1696
- 'an Object, but Boolean given.',
1697
- );
1698
- });
1699
1632
 
1700
- it('throws an error if false given', async function () {
1701
- const S = new Schema();
1702
- S.defineModel({
1703
- name: 'model',
1704
- datasource: 'datasource',
1705
- properties: {
1706
- foo: DataType.OBJECT,
1707
- },
1708
- });
1709
- const promise = S.getService(ModelDataValidator).validate('model', {
1710
- foo: false,
1633
+ it('does not throw an error if a null given', async function () {
1634
+ const S = new Schema();
1635
+ S.defineModel({
1636
+ name: 'model',
1637
+ datasource: 'datasource',
1638
+ properties: {
1639
+ foo: DataType.OBJECT,
1640
+ },
1641
+ });
1642
+ await S.getService(ModelDataValidator).validate('model', {
1643
+ foo: null,
1644
+ });
1711
1645
  });
1712
- await expect(promise).to.be.rejectedWith(
1713
- 'The property "foo" of the model "model" must have ' +
1714
- 'an Object, but Boolean given.',
1715
- );
1716
- });
1717
1646
 
1718
- it('throws an error if an array given', async function () {
1719
- const S = new Schema();
1720
- S.defineModel({
1721
- name: 'model',
1722
- datasource: 'datasource',
1723
- properties: {
1724
- foo: DataType.OBJECT,
1725
- },
1726
- });
1727
- const promise = S.getService(ModelDataValidator).validate('model', {
1728
- foo: [],
1647
+ it('throws an error if a string given', async function () {
1648
+ const S = new Schema();
1649
+ S.defineModel({
1650
+ name: 'model',
1651
+ datasource: 'datasource',
1652
+ properties: {
1653
+ foo: DataType.OBJECT,
1654
+ },
1655
+ });
1656
+ const promise = S.getService(ModelDataValidator).validate('model', {
1657
+ foo: 'bar',
1658
+ });
1659
+ await expect(promise).to.be.rejectedWith(
1660
+ 'The property "foo" of the model "model" must have ' +
1661
+ 'an Object, but String given.',
1662
+ );
1729
1663
  });
1730
- await expect(promise).to.be.rejectedWith(
1731
- 'The property "foo" of the model "model" must have ' +
1732
- 'an Object, but Array given.',
1733
- );
1734
- });
1735
1664
 
1736
- it('does not throw an error if an object given', async function () {
1737
- const S = new Schema();
1738
- S.defineModel({
1739
- name: 'model',
1740
- datasource: 'datasource',
1741
- properties: {
1742
- foo: DataType.OBJECT,
1743
- },
1744
- });
1745
- await S.getService(ModelDataValidator).validate('model', {
1746
- foo: {},
1665
+ it('throws an error if a number given', async function () {
1666
+ const S = new Schema();
1667
+ S.defineModel({
1668
+ name: 'model',
1669
+ datasource: 'datasource',
1670
+ properties: {
1671
+ foo: DataType.OBJECT,
1672
+ },
1673
+ });
1674
+ const promise = S.getService(ModelDataValidator).validate('model', {
1675
+ foo: 10,
1676
+ });
1677
+ await expect(promise).to.be.rejectedWith(
1678
+ 'The property "foo" of the model "model" must have ' +
1679
+ 'an Object, but Number given.',
1680
+ );
1747
1681
  });
1748
- });
1749
- });
1750
1682
 
1751
- describe('FullPropertyDefinition', function () {
1752
- it('does not throw an error if an undefined given', async function () {
1753
- const S = new Schema();
1754
- S.defineModel({
1755
- name: 'model',
1756
- datasource: 'datasource',
1757
- properties: {
1758
- foo: {
1759
- type: DataType.OBJECT,
1683
+ it('throws an error if true given', async function () {
1684
+ const S = new Schema();
1685
+ S.defineModel({
1686
+ name: 'model',
1687
+ datasource: 'datasource',
1688
+ properties: {
1689
+ foo: DataType.OBJECT,
1760
1690
  },
1761
- },
1762
- });
1763
- await S.getService(ModelDataValidator).validate('model', {
1764
- foo: undefined,
1691
+ });
1692
+ const promise = S.getService(ModelDataValidator).validate('model', {
1693
+ foo: true,
1694
+ });
1695
+ await expect(promise).to.be.rejectedWith(
1696
+ 'The property "foo" of the model "model" must have ' +
1697
+ 'an Object, but Boolean given.',
1698
+ );
1765
1699
  });
1766
- });
1767
1700
 
1768
- it('does not throw an error if a null given', async function () {
1769
- const S = new Schema();
1770
- S.defineModel({
1771
- name: 'model',
1772
- datasource: 'datasource',
1773
- properties: {
1774
- foo: {
1775
- type: DataType.OBJECT,
1701
+ it('throws an error if false given', async function () {
1702
+ const S = new Schema();
1703
+ S.defineModel({
1704
+ name: 'model',
1705
+ datasource: 'datasource',
1706
+ properties: {
1707
+ foo: DataType.OBJECT,
1776
1708
  },
1777
- },
1778
- });
1779
- await S.getService(ModelDataValidator).validate('model', {
1780
- foo: null,
1709
+ });
1710
+ const promise = S.getService(ModelDataValidator).validate('model', {
1711
+ foo: false,
1712
+ });
1713
+ await expect(promise).to.be.rejectedWith(
1714
+ 'The property "foo" of the model "model" must have ' +
1715
+ 'an Object, but Boolean given.',
1716
+ );
1781
1717
  });
1782
- });
1783
1718
 
1784
- it('throws an error if a string given', async function () {
1785
- const S = new Schema();
1786
- S.defineModel({
1787
- name: 'model',
1788
- datasource: 'datasource',
1789
- properties: {
1790
- foo: {
1791
- type: DataType.OBJECT,
1719
+ it('throws an error if an array given', async function () {
1720
+ const S = new Schema();
1721
+ S.defineModel({
1722
+ name: 'model',
1723
+ datasource: 'datasource',
1724
+ properties: {
1725
+ foo: DataType.OBJECT,
1792
1726
  },
1793
- },
1794
- });
1795
- const promise = S.getService(ModelDataValidator).validate('model', {
1796
- foo: 'bar',
1727
+ });
1728
+ const promise = S.getService(ModelDataValidator).validate('model', {
1729
+ foo: [],
1730
+ });
1731
+ await expect(promise).to.be.rejectedWith(
1732
+ 'The property "foo" of the model "model" must have ' +
1733
+ 'an Object, but Array given.',
1734
+ );
1797
1735
  });
1798
- await expect(promise).to.be.rejectedWith(
1799
- 'The property "foo" of the model "model" must have ' +
1800
- 'an Object, but String given.',
1801
- );
1802
- });
1803
1736
 
1804
- it('throws an error if a number given', async function () {
1805
- const S = new Schema();
1806
- S.defineModel({
1807
- name: 'model',
1808
- datasource: 'datasource',
1809
- properties: {
1810
- foo: {
1811
- type: DataType.OBJECT,
1737
+ it('does not throw an error if an object given', async function () {
1738
+ const S = new Schema();
1739
+ S.defineModel({
1740
+ name: 'model',
1741
+ datasource: 'datasource',
1742
+ properties: {
1743
+ foo: DataType.OBJECT,
1812
1744
  },
1813
- },
1814
- });
1815
- const promise = S.getService(ModelDataValidator).validate('model', {
1816
- foo: 10,
1745
+ });
1746
+ await S.getService(ModelDataValidator).validate('model', {
1747
+ foo: {},
1748
+ });
1817
1749
  });
1818
- await expect(promise).to.be.rejectedWith(
1819
- 'The property "foo" of the model "model" must have ' +
1820
- 'an Object, but Number given.',
1821
- );
1822
1750
  });
1823
1751
 
1824
- it('throws an error if true given', async function () {
1825
- const S = new Schema();
1826
- S.defineModel({
1827
- name: 'model',
1828
- datasource: 'datasource',
1829
- properties: {
1830
- foo: {
1831
- type: DataType.OBJECT,
1752
+ describe('FullPropertyDefinition', function () {
1753
+ it('does not throw an error if an undefined given', async function () {
1754
+ const S = new Schema();
1755
+ S.defineModel({
1756
+ name: 'model',
1757
+ datasource: 'datasource',
1758
+ properties: {
1759
+ foo: {
1760
+ type: DataType.OBJECT,
1761
+ },
1832
1762
  },
1833
- },
1834
- });
1835
- const promise = S.getService(ModelDataValidator).validate('model', {
1836
- foo: true,
1763
+ });
1764
+ await S.getService(ModelDataValidator).validate('model', {
1765
+ foo: undefined,
1766
+ });
1837
1767
  });
1838
- await expect(promise).to.be.rejectedWith(
1839
- 'The property "foo" of the model "model" must have ' +
1840
- 'an Object, but Boolean given.',
1841
- );
1842
- });
1843
1768
 
1844
- it('throws an error if false given', async function () {
1845
- const S = new Schema();
1846
- S.defineModel({
1847
- name: 'model',
1848
- datasource: 'datasource',
1849
- properties: {
1850
- foo: {
1851
- type: DataType.OBJECT,
1769
+ it('does not throw an error if a null given', async function () {
1770
+ const S = new Schema();
1771
+ S.defineModel({
1772
+ name: 'model',
1773
+ datasource: 'datasource',
1774
+ properties: {
1775
+ foo: {
1776
+ type: DataType.OBJECT,
1777
+ },
1852
1778
  },
1853
- },
1854
- });
1855
- const promise = S.getService(ModelDataValidator).validate('model', {
1856
- foo: false,
1779
+ });
1780
+ await S.getService(ModelDataValidator).validate('model', {
1781
+ foo: null,
1782
+ });
1857
1783
  });
1858
- await expect(promise).to.be.rejectedWith(
1859
- 'The property "foo" of the model "model" must have ' +
1860
- 'an Object, but Boolean given.',
1861
- );
1862
- });
1863
1784
 
1864
- it('throws an error if an array given', async function () {
1865
- const S = new Schema();
1866
- S.defineModel({
1867
- name: 'model',
1868
- datasource: 'datasource',
1869
- properties: {
1870
- foo: {
1871
- type: DataType.OBJECT,
1785
+ it('throws an error if a string given', async function () {
1786
+ const S = new Schema();
1787
+ S.defineModel({
1788
+ name: 'model',
1789
+ datasource: 'datasource',
1790
+ properties: {
1791
+ foo: {
1792
+ type: DataType.OBJECT,
1793
+ },
1872
1794
  },
1873
- },
1874
- });
1875
- const promise = S.getService(ModelDataValidator).validate('model', {
1876
- foo: [],
1795
+ });
1796
+ const promise = S.getService(ModelDataValidator).validate('model', {
1797
+ foo: 'bar',
1798
+ });
1799
+ await expect(promise).to.be.rejectedWith(
1800
+ 'The property "foo" of the model "model" must have ' +
1801
+ 'an Object, but String given.',
1802
+ );
1877
1803
  });
1878
- await expect(promise).to.be.rejectedWith(
1879
- 'The property "foo" of the model "model" must have ' +
1880
- 'an Object, but Array given.',
1881
- );
1882
- });
1883
1804
 
1884
- it('does not throw an error if an object given', async function () {
1885
- const S = new Schema();
1886
- S.defineModel({
1887
- name: 'model',
1888
- datasource: 'datasource',
1889
- properties: {
1890
- foo: {
1891
- type: DataType.OBJECT,
1805
+ it('throws an error if a number given', async function () {
1806
+ const S = new Schema();
1807
+ S.defineModel({
1808
+ name: 'model',
1809
+ datasource: 'datasource',
1810
+ properties: {
1811
+ foo: {
1812
+ type: DataType.OBJECT,
1813
+ },
1892
1814
  },
1893
- },
1894
- });
1895
- await S.getService(ModelDataValidator).validate('model', {
1896
- foo: {},
1815
+ });
1816
+ const promise = S.getService(ModelDataValidator).validate('model', {
1817
+ foo: 10,
1818
+ });
1819
+ await expect(promise).to.be.rejectedWith(
1820
+ 'The property "foo" of the model "model" must have ' +
1821
+ 'an Object, but Number given.',
1822
+ );
1897
1823
  });
1898
- });
1899
1824
 
1900
- describe('the "model" option', function () {
1901
- it('throws an error when the given object has an invalid model', async function () {
1825
+ it('throws an error if true given', async function () {
1902
1826
  const S = new Schema();
1903
1827
  S.defineModel({
1904
- name: 'modelA',
1828
+ name: 'model',
1829
+ datasource: 'datasource',
1905
1830
  properties: {
1906
- foo: DataType.STRING,
1831
+ foo: {
1832
+ type: DataType.OBJECT,
1833
+ },
1907
1834
  },
1908
1835
  });
1836
+ const promise = S.getService(ModelDataValidator).validate('model', {
1837
+ foo: true,
1838
+ });
1839
+ await expect(promise).to.be.rejectedWith(
1840
+ 'The property "foo" of the model "model" must have ' +
1841
+ 'an Object, but Boolean given.',
1842
+ );
1843
+ });
1844
+
1845
+ it('throws an error if false given', async function () {
1846
+ const S = new Schema();
1909
1847
  S.defineModel({
1910
- name: 'modelB',
1848
+ name: 'model',
1911
1849
  datasource: 'datasource',
1912
1850
  properties: {
1913
- bar: {
1851
+ foo: {
1914
1852
  type: DataType.OBJECT,
1915
- model: 'modelA',
1916
1853
  },
1917
1854
  },
1918
1855
  });
1919
- const promise = S.getService(ModelDataValidator).validate(
1920
- 'modelB',
1921
- {
1922
- bar: {foo: 10},
1923
- },
1924
- );
1856
+ const promise = S.getService(ModelDataValidator).validate('model', {
1857
+ foo: false,
1858
+ });
1925
1859
  await expect(promise).to.be.rejectedWith(
1926
- 'The property "foo" of the model "modelA" must have ' +
1927
- 'a String, but Number given.',
1860
+ 'The property "foo" of the model "model" must have ' +
1861
+ 'an Object, but Boolean given.',
1928
1862
  );
1929
1863
  });
1930
1864
 
1931
- it('does not throw an error when the given object has a valid model', async function () {
1865
+ it('throws an error if an array given', async function () {
1932
1866
  const S = new Schema();
1933
1867
  S.defineModel({
1934
- name: 'modelA',
1868
+ name: 'model',
1869
+ datasource: 'datasource',
1935
1870
  properties: {
1936
- foo: DataType.STRING,
1871
+ foo: {
1872
+ type: DataType.OBJECT,
1873
+ },
1937
1874
  },
1938
1875
  });
1876
+ const promise = S.getService(ModelDataValidator).validate('model', {
1877
+ foo: [],
1878
+ });
1879
+ await expect(promise).to.be.rejectedWith(
1880
+ 'The property "foo" of the model "model" must have ' +
1881
+ 'an Object, but Array given.',
1882
+ );
1883
+ });
1884
+
1885
+ it('does not throw an error if an object given', async function () {
1886
+ const S = new Schema();
1939
1887
  S.defineModel({
1940
- name: 'modelB',
1888
+ name: 'model',
1941
1889
  datasource: 'datasource',
1942
1890
  properties: {
1943
- bar: {
1891
+ foo: {
1944
1892
  type: DataType.OBJECT,
1945
- model: 'modelA',
1946
1893
  },
1947
1894
  },
1948
1895
  });
1949
- await S.getService(ModelDataValidator).validate('modelB', {
1950
- bar: {foo: '10'},
1896
+ await S.getService(ModelDataValidator).validate('model', {
1897
+ foo: {},
1898
+ });
1899
+ });
1900
+
1901
+ describe('the "model" option', function () {
1902
+ it('throws an error when the given object has an invalid model', async function () {
1903
+ const S = new Schema();
1904
+ S.defineModel({
1905
+ name: 'modelA',
1906
+ properties: {
1907
+ foo: DataType.STRING,
1908
+ },
1909
+ });
1910
+ S.defineModel({
1911
+ name: 'modelB',
1912
+ datasource: 'datasource',
1913
+ properties: {
1914
+ bar: {
1915
+ type: DataType.OBJECT,
1916
+ model: 'modelA',
1917
+ },
1918
+ },
1919
+ });
1920
+ const promise = S.getService(ModelDataValidator).validate(
1921
+ 'modelB',
1922
+ {
1923
+ bar: {foo: 10},
1924
+ },
1925
+ );
1926
+ await expect(promise).to.be.rejectedWith(
1927
+ 'The property "foo" of the model "modelA" must have ' +
1928
+ 'a String, but Number given.',
1929
+ );
1930
+ });
1931
+
1932
+ it('does not throw an error when the given object has a valid model', async function () {
1933
+ const S = new Schema();
1934
+ S.defineModel({
1935
+ name: 'modelA',
1936
+ properties: {
1937
+ foo: DataType.STRING,
1938
+ },
1939
+ });
1940
+ S.defineModel({
1941
+ name: 'modelB',
1942
+ datasource: 'datasource',
1943
+ properties: {
1944
+ bar: {
1945
+ type: DataType.OBJECT,
1946
+ model: 'modelA',
1947
+ },
1948
+ },
1949
+ });
1950
+ await S.getService(ModelDataValidator).validate('modelB', {
1951
+ bar: {foo: '10'},
1952
+ });
1951
1953
  });
1952
1954
  });
1953
1955
  });
@@ -1958,8 +1960,10 @@ describe('ModelDataValidator', function () {
1958
1960
  describe('the option "validate" with the string value', function () {
1959
1961
  it('do not validate null and undefined values', async function () {
1960
1962
  const S = new Schema();
1961
- S.getService(PropertyValidatorRegistry)
1962
- .addValidator('validator', () => false);
1963
+ S.getService(PropertyValidatorRegistry).addValidator(
1964
+ 'validator',
1965
+ () => false,
1966
+ );
1963
1967
  S.defineModel({
1964
1968
  name: 'model',
1965
1969
  properties: {
@@ -1986,10 +1990,12 @@ describe('ModelDataValidator', function () {
1986
1990
  it('throws an error from the validator', async function () {
1987
1991
  const validator = function () {
1988
1992
  throw Error('My error');
1989
- }
1993
+ };
1990
1994
  const S = new Schema();
1991
- S.getService(PropertyValidatorRegistry)
1992
- .addValidator('validator', validator);
1995
+ S.getService(PropertyValidatorRegistry).addValidator(
1996
+ 'validator',
1997
+ validator,
1998
+ );
1993
1999
  S.defineModel({
1994
2000
  name: 'model',
1995
2001
  properties: {
@@ -2007,8 +2013,10 @@ describe('ModelDataValidator', function () {
2007
2013
 
2008
2014
  it('allows the given value if the validator returns true', async function () {
2009
2015
  const S = new Schema();
2010
- S.getService(PropertyValidatorRegistry)
2011
- .addValidator('validator', () => true);
2016
+ S.getService(PropertyValidatorRegistry).addValidator(
2017
+ 'validator',
2018
+ () => true,
2019
+ );
2012
2020
  S.defineModel({
2013
2021
  name: 'model',
2014
2022
  properties: {
@@ -2025,8 +2033,10 @@ describe('ModelDataValidator', function () {
2025
2033
 
2026
2034
  it('allows the given value if the validator returns a promise of true', async function () {
2027
2035
  const S = new Schema();
2028
- S.getService(PropertyValidatorRegistry)
2029
- .addValidator('validator', () => Promise.resolve(true));
2036
+ S.getService(PropertyValidatorRegistry).addValidator(
2037
+ 'validator',
2038
+ () => Promise.resolve(true),
2039
+ );
2030
2040
  S.defineModel({
2031
2041
  name: 'model',
2032
2042
  properties: {
@@ -2042,10 +2052,12 @@ describe('ModelDataValidator', function () {
2042
2052
  });
2043
2053
 
2044
2054
  it('throws an error for non-true result from the validator', async function () {
2045
- const testFn = async (v) => {
2055
+ const testFn = async v => {
2046
2056
  const S = new Schema();
2047
- S.getService(PropertyValidatorRegistry)
2048
- .addValidator('validator', () => v);
2057
+ S.getService(PropertyValidatorRegistry).addValidator(
2058
+ 'validator',
2059
+ () => v,
2060
+ );
2049
2061
  S.defineModel({
2050
2062
  name: 'model',
2051
2063
  properties: {
@@ -2055,13 +2067,14 @@ describe('ModelDataValidator', function () {
2055
2067
  },
2056
2068
  },
2057
2069
  });
2058
- const promise = S.getService(ModelDataValidator)
2059
- .validate('model', {foo: 'test'});
2070
+ const promise = S.getService(ModelDataValidator).validate('model', {
2071
+ foo: 'test',
2072
+ });
2060
2073
  return expect(promise).to.be.rejectedWith(
2061
2074
  'The property "foo" of the model "model" has an invalid value "test" ' +
2062
- 'that caught by the validator "validator".',
2075
+ 'that caught by the validator "validator".',
2063
2076
  );
2064
- }
2077
+ };
2065
2078
  await testFn('str');
2066
2079
  await testFn('');
2067
2080
  await testFn(10);
@@ -2092,9 +2105,11 @@ describe('ModelDataValidator', function () {
2092
2105
  });
2093
2106
  validated = true;
2094
2107
  return true;
2095
- }
2096
- S.getService(PropertyValidatorRegistry)
2097
- .addValidator('validator', validator);
2108
+ };
2109
+ S.getService(PropertyValidatorRegistry).addValidator(
2110
+ 'validator',
2111
+ validator,
2112
+ );
2098
2113
  S.defineModel({
2099
2114
  name: 'model',
2100
2115
  properties: {
@@ -2115,10 +2130,12 @@ describe('ModelDataValidator', function () {
2115
2130
  const validator = function () {
2116
2131
  invoked++;
2117
2132
  return true;
2118
- }
2133
+ };
2119
2134
  const S = new Schema();
2120
- S.getService(PropertyValidatorRegistry)
2121
- .addValidator('validator', validator);
2135
+ S.getService(PropertyValidatorRegistry).addValidator(
2136
+ 'validator',
2137
+ validator,
2138
+ );
2122
2139
  S.defineModel({
2123
2140
  name: 'model',
2124
2141
  properties: {
@@ -2140,10 +2157,12 @@ describe('ModelDataValidator', function () {
2140
2157
  return new Promise((resolve, reject) => {
2141
2158
  setTimeout(() => reject(error), 5);
2142
2159
  });
2143
- }
2160
+ };
2144
2161
  const S = new Schema();
2145
- S.getService(PropertyValidatorRegistry)
2146
- .addValidator('validator', validator);
2162
+ S.getService(PropertyValidatorRegistry).addValidator(
2163
+ 'validator',
2164
+ validator,
2165
+ );
2147
2166
  S.defineModel({
2148
2167
  name: 'model',
2149
2168
  properties: {
@@ -2179,8 +2198,10 @@ describe('ModelDataValidator', function () {
2179
2198
 
2180
2199
  it('do not validate null and undefined values', async function () {
2181
2200
  const S = new Schema();
2182
- S.getService(PropertyValidatorRegistry)
2183
- .addValidator('validator', () => false);
2201
+ S.getService(PropertyValidatorRegistry).addValidator(
2202
+ 'validator',
2203
+ () => false,
2204
+ );
2184
2205
  S.defineModel({
2185
2206
  name: 'model',
2186
2207
  properties: {
@@ -2207,10 +2228,12 @@ describe('ModelDataValidator', function () {
2207
2228
  it('throws an error from the validator', async function () {
2208
2229
  const validator = function () {
2209
2230
  throw Error('My error');
2210
- }
2231
+ };
2211
2232
  const S = new Schema();
2212
- S.getService(PropertyValidatorRegistry)
2213
- .addValidator('validator', validator);
2233
+ S.getService(PropertyValidatorRegistry).addValidator(
2234
+ 'validator',
2235
+ validator,
2236
+ );
2214
2237
  S.defineModel({
2215
2238
  name: 'model',
2216
2239
  properties: {
@@ -2284,9 +2307,9 @@ describe('ModelDataValidator', function () {
2284
2307
  });
2285
2308
  return expect(promise).to.be.rejectedWith(
2286
2309
  'The property "foo" of the model "model" has an invalid value "test" ' +
2287
- 'that caught by the validator "validator2".',
2310
+ 'that caught by the validator "validator2".',
2288
2311
  );
2289
- }
2312
+ };
2290
2313
  await testFn('str');
2291
2314
  await testFn('');
2292
2315
  await testFn(10);
@@ -2317,9 +2340,11 @@ describe('ModelDataValidator', function () {
2317
2340
  });
2318
2341
  validated = true;
2319
2342
  return true;
2320
- }
2321
- S.getService(PropertyValidatorRegistry)
2322
- .addValidator('validator', validator);
2343
+ };
2344
+ S.getService(PropertyValidatorRegistry).addValidator(
2345
+ 'validator',
2346
+ validator,
2347
+ );
2323
2348
  S.defineModel({
2324
2349
  name: 'model',
2325
2350
  properties: {
@@ -2340,11 +2365,11 @@ describe('ModelDataValidator', function () {
2340
2365
  const validator1 = function () {
2341
2366
  invocation.push('validator1');
2342
2367
  return true;
2343
- }
2368
+ };
2344
2369
  const validator2 = function () {
2345
2370
  invocation.push('validator2');
2346
2371
  return true;
2347
- }
2372
+ };
2348
2373
  const S = new Schema();
2349
2374
  S.getService(PropertyValidatorRegistry)
2350
2375
  .addValidator('validator1', validator1)
@@ -2367,12 +2392,14 @@ describe('ModelDataValidator', function () {
2367
2392
  it('waits rejection from one of async validators', async function () {
2368
2393
  const error1 = new Error('Occurs after 15 ms');
2369
2394
  const error2 = new Error('Occurs after 5 ms');
2370
- const validator1 = () => new Promise((res, rej) => {
2371
- setTimeout(() => rej(error1), 15);
2372
- });
2373
- const validator2 = () => new Promise((res, rej) => {
2374
- setTimeout(() => rej(error2), 5);
2375
- });
2395
+ const validator1 = () =>
2396
+ new Promise((res, rej) => {
2397
+ setTimeout(() => rej(error1), 15);
2398
+ });
2399
+ const validator2 = () =>
2400
+ new Promise((res, rej) => {
2401
+ setTimeout(() => rej(error2), 5);
2402
+ });
2376
2403
  const S = new Schema();
2377
2404
  S.getService(PropertyValidatorRegistry)
2378
2405
  .addValidator('validator1', validator1)
@@ -2382,10 +2409,7 @@ describe('ModelDataValidator', function () {
2382
2409
  properties: {
2383
2410
  foo: {
2384
2411
  type: DataType.ANY,
2385
- validate: [
2386
- 'validator1',
2387
- 'validator2',
2388
- ],
2412
+ validate: ['validator1', 'validator2'],
2389
2413
  },
2390
2414
  },
2391
2415
  });
@@ -2415,8 +2439,10 @@ describe('ModelDataValidator', function () {
2415
2439
 
2416
2440
  it('do not validate null and undefined values', async function () {
2417
2441
  const S = new Schema();
2418
- S.getService(PropertyValidatorRegistry)
2419
- .addValidator('validator', () => false);
2442
+ S.getService(PropertyValidatorRegistry).addValidator(
2443
+ 'validator',
2444
+ () => false,
2445
+ );
2420
2446
  S.defineModel({
2421
2447
  name: 'model',
2422
2448
  properties: {
@@ -2449,10 +2475,12 @@ describe('ModelDataValidator', function () {
2449
2475
  it('throws an error from the validator', async function () {
2450
2476
  const validator = function () {
2451
2477
  throw Error('My error');
2452
- }
2478
+ };
2453
2479
  const S = new Schema();
2454
- S.getService(PropertyValidatorRegistry)
2455
- .addValidator('validator', validator);
2480
+ S.getService(PropertyValidatorRegistry).addValidator(
2481
+ 'validator',
2482
+ validator,
2483
+ );
2456
2484
  S.defineModel({
2457
2485
  name: 'model',
2458
2486
  properties: {
@@ -2537,9 +2565,9 @@ describe('ModelDataValidator', function () {
2537
2565
  });
2538
2566
  return expect(promise).to.be.rejectedWith(
2539
2567
  'The property "foo" of the model "model" has an invalid value "test" ' +
2540
- 'that caught by the validator "validator2".',
2568
+ 'that caught by the validator "validator2".',
2541
2569
  );
2542
- }
2570
+ };
2543
2571
  await testFn('str');
2544
2572
  await testFn('');
2545
2573
  await testFn(10);
@@ -2578,9 +2606,11 @@ describe('ModelDataValidator', function () {
2578
2606
  });
2579
2607
  validated = true;
2580
2608
  return true;
2581
- }
2582
- S.getService(PropertyValidatorRegistry)
2583
- .addValidator('validator', validator);
2609
+ };
2610
+ S.getService(PropertyValidatorRegistry).addValidator(
2611
+ 'validator',
2612
+ validator,
2613
+ );
2584
2614
  S.defineModel({
2585
2615
  name: 'model',
2586
2616
  properties: {
@@ -2606,11 +2636,11 @@ describe('ModelDataValidator', function () {
2606
2636
  const validator1 = function () {
2607
2637
  invocation.push('validator1');
2608
2638
  return true;
2609
- }
2639
+ };
2610
2640
  const validator2 = function () {
2611
2641
  invocation.push('validator2');
2612
2642
  return true;
2613
- }
2643
+ };
2614
2644
  const S = new Schema();
2615
2645
  S.getService(PropertyValidatorRegistry)
2616
2646
  .addValidator('validator1', validator1)
@@ -2638,10 +2668,12 @@ describe('ModelDataValidator', function () {
2638
2668
  const validator = function () {
2639
2669
  validated = true;
2640
2670
  return true;
2641
- }
2671
+ };
2642
2672
  const S = new Schema();
2643
- S.getService(PropertyValidatorRegistry)
2644
- .addValidator('validator', validator);
2673
+ S.getService(PropertyValidatorRegistry).addValidator(
2674
+ 'validator',
2675
+ validator,
2676
+ );
2645
2677
  S.defineModel({
2646
2678
  name: 'model',
2647
2679
  properties: {
@@ -2662,12 +2694,14 @@ describe('ModelDataValidator', function () {
2662
2694
  it('waits rejection from one of async validators', async function () {
2663
2695
  const error1 = new Error('Occurs after 15 ms');
2664
2696
  const error2 = new Error('Occurs after 5 ms');
2665
- const validator1 = () => new Promise((res, rej) => {
2666
- setTimeout(() => rej(error1), 15);
2667
- });
2668
- const validator2 = () => new Promise((res, rej) => {
2669
- setTimeout(() => rej(error2), 5);
2670
- });
2697
+ const validator1 = () =>
2698
+ new Promise((res, rej) => {
2699
+ setTimeout(() => rej(error1), 15);
2700
+ });
2701
+ const validator2 = () =>
2702
+ new Promise((res, rej) => {
2703
+ setTimeout(() => rej(error2), 5);
2704
+ });
2671
2705
  const S = new Schema();
2672
2706
  S.getService(PropertyValidatorRegistry)
2673
2707
  .addValidator('validator1', validator1)
@@ -2680,7 +2714,7 @@ describe('ModelDataValidator', function () {
2680
2714
  validate: {
2681
2715
  validator1: true,
2682
2716
  validator2: true,
2683
- }
2717
+ },
2684
2718
  },
2685
2719
  },
2686
2720
  });