@palmares/schemas 0.0.1 → 0.1.0

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 (174) hide show
  1. package/.turbo/turbo-build$colon$watch.log +12 -410
  2. package/CHANGELOG.md +17 -0
  3. package/__tests__/.drizzle/migrations/0000_skinny_harrier.sql +22 -0
  4. package/__tests__/.drizzle/migrations/meta/0000_snapshot.json +156 -0
  5. package/__tests__/.drizzle/migrations/meta/_journal.json +13 -0
  6. package/__tests__/.drizzle/schema.ts +35 -0
  7. package/__tests__/drizzle.config.ts +11 -0
  8. package/__tests__/eslint.config.js +10 -0
  9. package/__tests__/manage.ts +5 -0
  10. package/__tests__/node_modules/.bin/drizzle-kit +17 -0
  11. package/__tests__/node_modules/.bin/esbuild +14 -0
  12. package/__tests__/node_modules/.bin/tsc +17 -0
  13. package/__tests__/node_modules/.bin/tsserver +17 -0
  14. package/__tests__/node_modules/.bin/tsx +17 -0
  15. package/__tests__/package.json +36 -0
  16. package/__tests__/sqlite.db +0 -0
  17. package/__tests__/src/core/array.test.ts +130 -0
  18. package/__tests__/src/core/boolean.test.ts +66 -0
  19. package/__tests__/src/core/datetime.test.ts +102 -0
  20. package/__tests__/src/core/index.ts +35 -0
  21. package/__tests__/src/core/model.test.ts +260 -0
  22. package/__tests__/src/core/models.ts +50 -0
  23. package/__tests__/src/core/numbers.test.ts +177 -0
  24. package/__tests__/src/core/object.test.ts +198 -0
  25. package/__tests__/src/core/string.test.ts +222 -0
  26. package/__tests__/src/core/test.test.ts +59 -0
  27. package/__tests__/src/core/types.test.ts +97 -0
  28. package/__tests__/src/core/union.test.ts +99 -0
  29. package/__tests__/src/settings.ts +71 -0
  30. package/__tests__/tsconfig.json +11 -0
  31. package/dist/cjs/src/adapter/fields/index.js +2 -2
  32. package/dist/cjs/src/adapter/fields/object.js +9 -0
  33. package/dist/cjs/src/adapter/index.js +1 -0
  34. package/dist/cjs/src/constants.js +1 -7
  35. package/dist/cjs/src/domain.js +146 -1
  36. package/dist/cjs/src/index.js +69 -74
  37. package/dist/cjs/src/model.js +206 -206
  38. package/dist/cjs/src/schema/array.js +185 -58
  39. package/dist/cjs/src/schema/boolean.js +105 -44
  40. package/dist/cjs/src/schema/datetime.js +104 -38
  41. package/dist/cjs/src/schema/number.js +134 -114
  42. package/dist/cjs/src/schema/object.js +106 -43
  43. package/dist/cjs/src/schema/schema.js +123 -75
  44. package/dist/cjs/src/schema/string.js +152 -58
  45. package/dist/cjs/src/schema/union.js +412 -290
  46. package/dist/cjs/src/utils.js +42 -15
  47. package/dist/cjs/src/validators/array.js +6 -1
  48. package/dist/cjs/src/validators/boolean.js +2 -0
  49. package/dist/cjs/src/validators/datetime.js +4 -0
  50. package/dist/cjs/src/validators/number.js +12 -40
  51. package/dist/cjs/src/validators/object.js +1 -0
  52. package/dist/cjs/src/validators/schema.js +5 -1
  53. package/dist/cjs/src/validators/string.js +30 -2
  54. package/dist/cjs/src/validators/union.js +5 -4
  55. package/dist/cjs/src/validators/utils.js +99 -27
  56. package/dist/cjs/tsconfig.types.tsbuildinfo +1 -1
  57. package/dist/cjs/types/adapter/fields/array.d.ts +2 -2
  58. package/dist/cjs/types/adapter/fields/array.d.ts.map +1 -1
  59. package/dist/cjs/types/adapter/fields/boolean.d.ts.map +1 -1
  60. package/dist/cjs/types/adapter/fields/datetime.d.ts.map +1 -1
  61. package/dist/cjs/types/adapter/fields/index.d.ts +2 -2
  62. package/dist/cjs/types/adapter/fields/index.d.ts.map +1 -1
  63. package/dist/cjs/types/adapter/fields/number.d.ts.map +1 -1
  64. package/dist/cjs/types/adapter/fields/object.d.ts +2 -1
  65. package/dist/cjs/types/adapter/fields/object.d.ts.map +1 -1
  66. package/dist/cjs/types/adapter/fields/string.d.ts.map +1 -1
  67. package/dist/cjs/types/adapter/fields/union.d.ts.map +1 -1
  68. package/dist/cjs/types/adapter/index.d.ts +1 -0
  69. package/dist/cjs/types/adapter/index.d.ts.map +1 -1
  70. package/dist/cjs/types/adapter/types.d.ts +28 -18
  71. package/dist/cjs/types/adapter/types.d.ts.map +1 -1
  72. package/dist/cjs/types/constants.d.ts +0 -1
  73. package/dist/cjs/types/constants.d.ts.map +1 -1
  74. package/dist/cjs/types/domain.d.ts +5 -4
  75. package/dist/cjs/types/domain.d.ts.map +1 -1
  76. package/dist/cjs/types/index.d.ts +78 -55
  77. package/dist/cjs/types/index.d.ts.map +1 -1
  78. package/dist/cjs/types/model.d.ts +17 -17
  79. package/dist/cjs/types/model.d.ts.map +1 -1
  80. package/dist/cjs/types/schema/array.d.ts +168 -47
  81. package/dist/cjs/types/schema/array.d.ts.map +1 -1
  82. package/dist/cjs/types/schema/boolean.d.ts +103 -44
  83. package/dist/cjs/types/schema/boolean.d.ts.map +1 -1
  84. package/dist/cjs/types/schema/datetime.d.ts +90 -30
  85. package/dist/cjs/types/schema/datetime.d.ts.map +1 -1
  86. package/dist/cjs/types/schema/number.d.ts +133 -125
  87. package/dist/cjs/types/schema/number.d.ts.map +1 -1
  88. package/dist/cjs/types/schema/object.d.ts +104 -35
  89. package/dist/cjs/types/schema/object.d.ts.map +1 -1
  90. package/dist/cjs/types/schema/schema.d.ts +62 -44
  91. package/dist/cjs/types/schema/schema.d.ts.map +1 -1
  92. package/dist/cjs/types/schema/string.d.ts +152 -65
  93. package/dist/cjs/types/schema/string.d.ts.map +1 -1
  94. package/dist/cjs/types/schema/types.d.ts +11 -2
  95. package/dist/cjs/types/schema/types.d.ts.map +1 -1
  96. package/dist/cjs/types/schema/union.d.ts +133 -40
  97. package/dist/cjs/types/schema/union.d.ts.map +1 -1
  98. package/dist/cjs/types/types.d.ts +35 -0
  99. package/dist/cjs/types/types.d.ts.map +1 -1
  100. package/dist/cjs/types/utils.d.ts +41 -27
  101. package/dist/cjs/types/utils.d.ts.map +1 -1
  102. package/dist/cjs/types/validators/array.d.ts.map +1 -1
  103. package/dist/cjs/types/validators/boolean.d.ts.map +1 -1
  104. package/dist/cjs/types/validators/datetime.d.ts.map +1 -1
  105. package/dist/cjs/types/validators/number.d.ts +5 -6
  106. package/dist/cjs/types/validators/number.d.ts.map +1 -1
  107. package/dist/cjs/types/validators/object.d.ts.map +1 -1
  108. package/dist/cjs/types/validators/schema.d.ts +2 -2
  109. package/dist/cjs/types/validators/schema.d.ts.map +1 -1
  110. package/dist/cjs/types/validators/string.d.ts +9 -9
  111. package/dist/cjs/types/validators/string.d.ts.map +1 -1
  112. package/dist/cjs/types/validators/utils.d.ts +44 -27
  113. package/dist/cjs/types/validators/utils.d.ts.map +1 -1
  114. package/dist/esm/src/adapter/fields/index.js +2 -2
  115. package/dist/esm/src/adapter/fields/object.js +6 -0
  116. package/dist/esm/src/adapter/index.js +1 -0
  117. package/dist/esm/src/constants.js +1 -2
  118. package/dist/esm/src/domain.js +11 -1
  119. package/dist/esm/src/index.js +38 -73
  120. package/dist/esm/src/model.js +83 -78
  121. package/dist/esm/src/schema/array.js +136 -54
  122. package/dist/esm/src/schema/boolean.js +98 -44
  123. package/dist/esm/src/schema/datetime.js +91 -38
  124. package/dist/esm/src/schema/number.js +127 -110
  125. package/dist/esm/src/schema/object.js +98 -43
  126. package/dist/esm/src/schema/schema.js +102 -67
  127. package/dist/esm/src/schema/string.js +147 -59
  128. package/dist/esm/src/schema/union.js +119 -40
  129. package/dist/esm/src/types.js +14 -1
  130. package/dist/esm/src/utils.js +56 -27
  131. package/dist/esm/src/validators/array.js +6 -1
  132. package/dist/esm/src/validators/boolean.js +2 -0
  133. package/dist/esm/src/validators/datetime.js +4 -0
  134. package/dist/esm/src/validators/number.js +9 -23
  135. package/dist/esm/src/validators/object.js +1 -0
  136. package/dist/esm/src/validators/schema.js +5 -1
  137. package/dist/esm/src/validators/string.js +30 -2
  138. package/dist/esm/src/validators/union.js +5 -4
  139. package/dist/esm/src/validators/utils.js +62 -36
  140. package/package.json +3 -3
  141. package/src/adapter/fields/array.ts +2 -2
  142. package/src/adapter/fields/boolean.ts +3 -8
  143. package/src/adapter/fields/datetime.ts +3 -9
  144. package/src/adapter/fields/index.ts +11 -11
  145. package/src/adapter/fields/number.ts +3 -9
  146. package/src/adapter/fields/object.ts +13 -10
  147. package/src/adapter/fields/string.ts +3 -9
  148. package/src/adapter/fields/union.ts +3 -9
  149. package/src/adapter/index.ts +1 -0
  150. package/src/adapter/types.ts +60 -45
  151. package/src/constants.ts +1 -3
  152. package/src/domain.ts +15 -1
  153. package/src/index.ts +189 -211
  154. package/src/model.ts +119 -115
  155. package/src/schema/array.ts +274 -90
  156. package/src/schema/boolean.ts +145 -60
  157. package/src/schema/datetime.ts +133 -49
  158. package/src/schema/number.ts +210 -173
  159. package/src/schema/object.ts +167 -74
  160. package/src/schema/schema.ts +205 -126
  161. package/src/schema/string.ts +221 -94
  162. package/src/schema/types.ts +44 -16
  163. package/src/schema/union.ts +193 -68
  164. package/src/types.ts +53 -0
  165. package/src/utils.ts +115 -57
  166. package/src/validators/array.ts +46 -27
  167. package/src/validators/boolean.ts +13 -7
  168. package/src/validators/datetime.ts +24 -16
  169. package/src/validators/number.ts +53 -63
  170. package/src/validators/object.ts +6 -5
  171. package/src/validators/schema.ts +33 -25
  172. package/src/validators/string.ts +122 -59
  173. package/src/validators/union.ts +8 -8
  174. package/src/validators/utils.ts +67 -42
@@ -24,6 +24,9 @@ _export(exports, {
24
24
  parseErrorsFactory: function() {
25
25
  return parseErrorsFactory;
26
26
  },
27
+ shouldRunDataOnComplexSchemas: function() {
28
+ return shouldRunDataOnComplexSchemas;
29
+ },
27
30
  transformSchemaAndCheckIfShouldBeHandledByFallbackOnComplexSchemas: function() {
28
31
  return transformSchemaAndCheckIfShouldBeHandledByFallbackOnComplexSchemas;
29
32
  },
@@ -31,6 +34,8 @@ _export(exports, {
31
34
  return withFallbackFactory;
32
35
  }
33
36
  });
37
+ var _adapter = /*#__PURE__*/ _interop_require_default(require("./adapter"));
38
+ var _conf = require("./conf");
34
39
  var _schema = require("./validators/schema");
35
40
  var _utils = /*#__PURE__*/ _interop_require_default(require("./validators/utils"));
36
41
  function _array_like_to_array(arr, len) {
@@ -313,7 +318,7 @@ function defaultTransform(type, schema, adapter, fieldAdapter, getValidationData
313
318
  }
314
319
  function _defaultTransform() {
315
320
  _defaultTransform = _async_to_generator(function(type, schema, adapter, fieldAdapter, getValidationData, fallbackFunctions, options) {
316
- var validationData, validationDataForStringVersion, _tmp, schemaWithPrivateFields, checkIfShouldUseParserAndAppend, getExtendedOrNotSchemaAndString, checkIfShouldAppendFallbackAndAppend, appendRootFallback, hasFallbacks, isFieldAdapterNotSupportedForThatFieldType, existingFallbacks, allParsers, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, fallback, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, parser, translatedSchemaOrWithFallback, stringVersion, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, fallback1, _getExtendedOrNotSchemaAndString, extendedOrNotSchema, extendedOrNotSchemaString, _getExtendedOrNotSchemaAndString1, extendedOrNotSchema1, extendedOrNotSchemaString1;
321
+ var validationData, validationDataForStringVersion, _tmp, schemaWithPrivateFields, checkIfShouldUseParserAndAppend, getExtendedOrNotSchemaAndString, checkIfShouldAppendFallbackAndAppend, appendRootFallback, appendRequiredFallbacks, isFieldAdapterNotSupportedForThatFieldType, existingFallbacks, allParsers, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, fallback, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, parser, translatedSchemaOrWithFallback, stringVersion, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, fallback1, _getExtendedOrNotSchemaAndString, extendedOrNotSchema, extendedOrNotSchemaString, _getExtendedOrNotSchemaAndString1, extendedOrNotSchema1, extendedOrNotSchemaString1;
317
322
  return _ts_generator(this, function(_state) {
318
323
  switch(_state.label){
319
324
  case 0:
@@ -391,13 +396,15 @@ function _defaultTransform() {
391
396
  }
392
397
  }
393
398
  };
394
- hasFallbacks = _instanceof(schemaWithPrivateFields.__rootFallbacksValidator, _utils.default);
399
+ appendRequiredFallbacks = function() {
400
+ var hasFallbacks = _instanceof(schemaWithPrivateFields.__rootFallbacksValidator, _utils.default);
401
+ if (hasFallbacks) {
402
+ _utils.default.createAndAppendFallback(schema, (0, _schema.optional)(schemaWithPrivateFields.__optional));
403
+ _utils.default.createAndAppendFallback(schema, (0, _schema.nullable)(schemaWithPrivateFields.__nullable));
404
+ _utils.default.createAndAppendFallback(schema, (0, _schema.checkType)(schemaWithPrivateFields.__type));
405
+ }
406
+ };
395
407
  isFieldAdapterNotSupportedForThatFieldType = fieldAdapter === undefined;
396
- if (hasFallbacks) {
397
- _utils.default.createAndAppendFallback(schema, (0, _schema.optional)(schemaWithPrivateFields.__optional));
398
- _utils.default.createAndAppendFallback(schema, (0, _schema.nullable)(schemaWithPrivateFields.__nullable));
399
- _utils.default.createAndAppendFallback(schema, (0, _schema.checkType)(schemaWithPrivateFields.__type));
400
- }
401
408
  if (options.fallbackIfNotSupported !== undefined && isFieldAdapterNotSupportedForThatFieldType) {
402
409
  existingFallbacks = Object.keys(fallbackFunctions);
403
410
  allParsers = Object.keys(validationData['parsers']);
@@ -442,6 +449,7 @@ function _defaultTransform() {
442
449
  }
443
450
  }
444
451
  }
452
+ appendRequiredFallbacks();
445
453
  return [
446
454
  2,
447
455
  options.fallbackIfNotSupported()
@@ -493,6 +501,7 @@ function _defaultTransform() {
493
501
  }
494
502
  }
495
503
  _getExtendedOrNotSchemaAndString = _sliced_to_array(getExtendedOrNotSchemaAndString(translatedSchemaOrWithFallback.transformedSchema, stringVersion), 2), extendedOrNotSchema = _getExtendedOrNotSchemaAndString[0], extendedOrNotSchemaString = _getExtendedOrNotSchemaAndString[1];
504
+ appendRequiredFallbacks();
496
505
  return [
497
506
  2,
498
507
  [
@@ -518,15 +527,24 @@ function _defaultTransform() {
518
527
  });
519
528
  return _defaultTransform.apply(this, arguments);
520
529
  }
521
- function defaultTransformToAdapter(callback, transformedSchemas, options, type) {
530
+ function defaultTransformToAdapter(callback, schema, transformedSchemas, options, type) {
522
531
  return _defaultTransformToAdapter.apply(this, arguments);
523
532
  }
524
533
  function _defaultTransformToAdapter() {
525
- _defaultTransformToAdapter = _async_to_generator(function(callback, transformedSchemas, options, type) {
526
- var _options_schemaAdapter, schemaAdapterNameToUse, isACustomSchemaAdapterAndNotYetDefined, shouldTranslate, translatedSchemas;
534
+ _defaultTransformToAdapter = _async_to_generator(function(callback, schema, transformedSchemas, options, type) {
535
+ var _options_schemaAdapter, isTransformedSchemasEmpty, adapterInstanceToUse, schemaAdapterNameToUse, isACustomSchemaAdapterAndNotYetDefined, shouldTranslate, translatedSchemas;
527
536
  return _ts_generator(this, function(_state) {
528
537
  switch(_state.label){
529
538
  case 0:
539
+ isTransformedSchemasEmpty = Object.keys(transformedSchemas).length <= 0;
540
+ if (isTransformedSchemasEmpty) {
541
+ adapterInstanceToUse = _instanceof(options.schemaAdapter, _adapter.default) ? options.schemaAdapter : (0, _conf.getDefaultAdapter)();
542
+ schema['__transformedSchemas'][adapterInstanceToUse.constructor.name] = {
543
+ transformed: false,
544
+ adapter: adapterInstanceToUse,
545
+ schemas: []
546
+ };
547
+ }
530
548
  schemaAdapterNameToUse = ((_options_schemaAdapter = options.schemaAdapter) === null || _options_schemaAdapter === void 0 ? void 0 : _options_schemaAdapter.constructor.name) || Object.keys(transformedSchemas)[0];
531
549
  isACustomSchemaAdapterAndNotYetDefined = // eslint-disable-next-line ts/no-unnecessary-condition
532
550
  transformedSchemas[schemaAdapterNameToUse] === undefined && options.schemaAdapter !== undefined;
@@ -560,25 +578,31 @@ function _defaultTransformToAdapter() {
560
578
  });
561
579
  return _defaultTransformToAdapter.apply(this, arguments);
562
580
  }
563
- function formatErrorFromParseMethod(adapter, fieldAdapter, error, path, errorsAsHashedSet) {
581
+ function formatErrorFromParseMethod(adapter, fieldAdapter, error, received, schema, path, errorsAsHashedSet) {
564
582
  return _formatErrorFromParseMethod.apply(this, arguments);
565
583
  }
566
584
  function _formatErrorFromParseMethod() {
567
- _formatErrorFromParseMethod = _async_to_generator(function(adapter, fieldAdapter, error, path, errorsAsHashedSet) {
568
- var formattedError, formattedErrorAsParseResultError;
585
+ _formatErrorFromParseMethod = _async_to_generator(function(adapter, fieldAdapter, error, received, schema, path, errorsAsHashedSet) {
586
+ var formattedError, formattedErrorAsParseResultError, sortedError, hashedError;
569
587
  return _ts_generator(this, function(_state) {
570
588
  switch(_state.label){
571
589
  case 0:
572
590
  return [
573
591
  4,
574
- fieldAdapter.formatError(adapter, fieldAdapter, error)
592
+ fieldAdapter.formatError(adapter, adapter.field, schema, error)
575
593
  ];
576
594
  case 1:
577
595
  formattedError = _state.sent();
578
596
  formattedError.path = Array.isArray(formattedError.path) ? _to_consumable_array(path).concat(_to_consumable_array(formattedError.path)) : path;
579
597
  formattedErrorAsParseResultError = formattedError;
580
598
  formattedErrorAsParseResultError.isValid = false;
581
- errorsAsHashedSet.add(JSON.stringify(formattedErrorAsParseResultError));
599
+ sortedError = Object.fromEntries(Object.entries(formattedErrorAsParseResultError).sort(function(param, param1) {
600
+ var _param = _sliced_to_array(param, 1), a = _param[0], _param1 = _sliced_to_array(param1, 1), b = _param1[0];
601
+ return a.localeCompare(b);
602
+ }));
603
+ hashedError = JSON.stringify(sortedError);
604
+ errorsAsHashedSet.add(JSON.stringify(sortedError));
605
+ formattedErrorAsParseResultError.received = received;
582
606
  return [
583
607
  2,
584
608
  formattedErrorAsParseResultError
@@ -625,3 +649,6 @@ function _transformSchemaAndCheckIfShouldBeHandledByFallbackOnComplexSchemas() {
625
649
  });
626
650
  return _transformSchemaAndCheckIfShouldBeHandledByFallbackOnComplexSchemas.apply(this, arguments);
627
651
  }
652
+ function shouldRunDataOnComplexSchemas(schema) {
653
+ return typeof schema['__parsersToTransformValue'] === 'function' || typeof schema['__runBeforeParseAndData'] === 'function' || typeof schema['__toRepresentation'] === 'function' || typeof schema['__defaultFunction'] === 'function';
654
+ }
@@ -191,6 +191,7 @@ function _ts_values(o) {
191
191
  }
192
192
  function arrayValidation(isTuple, schemas) {
193
193
  return {
194
+ name: 'array',
194
195
  type: 'medium',
195
196
  callback: function() {
196
197
  var _ref = _async_to_generator(function(value, path, options) {
@@ -232,7 +233,8 @@ function arrayValidation(isTuple, schemas) {
232
233
  }
233
234
  ];
234
235
  errorsOfArray = [];
235
- // To speed things up, we can do a simple type check, if the value is of type number and number is on index 1, and on index 0 is a string,
236
+ // To speed things up, we can do a simple type check, if the value is of type number and
237
+ // number is on index 1, and on index 0 is a string,
236
238
  // if the value is a number we can skip checking at index 0.
237
239
  schemaIndexByTypeof = new Map();
238
240
  parsedValues = [];
@@ -361,6 +363,7 @@ function arrayValidation(isTuple, schemas) {
361
363
  }
362
364
  function minLength(args) {
363
365
  return {
366
+ name: 'minLength',
364
367
  type: 'low',
365
368
  // eslint-disable-next-line ts/require-await
366
369
  callback: function() {
@@ -393,6 +396,7 @@ function minLength(args) {
393
396
  }
394
397
  function maxLength(args) {
395
398
  return {
399
+ name: 'maxLength',
396
400
  type: 'low',
397
401
  // eslint-disable-next-line ts/require-await
398
402
  callback: function() {
@@ -425,6 +429,7 @@ function maxLength(args) {
425
429
  }
426
430
  function nonEmpty(args) {
427
431
  return {
432
+ name: 'nonEmpty',
428
433
  type: 'low',
429
434
  // eslint-disable-next-line ts/require-await
430
435
  callback: function() {
@@ -142,6 +142,7 @@ function _ts_generator(thisArg, body) {
142
142
  }
143
143
  function booleanValidation() {
144
144
  return {
145
+ name: 'boolean',
145
146
  type: 'medium',
146
147
  // eslint-disable-next-line ts/require-await
147
148
  callback: function() {
@@ -175,6 +176,7 @@ function booleanValidation() {
175
176
  }
176
177
  function allowStringParser() {
177
178
  return {
179
+ name: 'allowString',
178
180
  type: 'high',
179
181
  // eslint-disable-next-line ts/require-await
180
182
  callback: function() {
@@ -155,6 +155,7 @@ function _ts_generator(thisArg, body) {
155
155
  }
156
156
  function datetimeValidation() {
157
157
  return {
158
+ name: 'datetime',
158
159
  type: 'medium',
159
160
  // eslint-disable-next-line ts/require-await
160
161
  callback: function() {
@@ -188,6 +189,7 @@ function datetimeValidation() {
188
189
  }
189
190
  function allowStringParser() {
190
191
  return {
192
+ name: 'allowString',
191
193
  type: 'high',
192
194
  // eslint-disable-next-line ts/require-await
193
195
  callback: function() {
@@ -223,6 +225,7 @@ function allowStringParser() {
223
225
  }
224
226
  function below(args) {
225
227
  return {
228
+ name: 'below',
226
229
  type: 'low',
227
230
  // eslint-disable-next-line ts/require-await
228
231
  callback: function() {
@@ -255,6 +258,7 @@ function below(args) {
255
258
  }
256
259
  function above(args) {
257
260
  return {
261
+ name: 'above',
258
262
  type: 'low',
259
263
  // eslint-disable-next-line ts/require-await
260
264
  callback: function() {
@@ -12,6 +12,9 @@ _export(exports, {
12
12
  decimalPlaces: function() {
13
13
  return decimalPlaces;
14
14
  },
15
+ integer: function() {
16
+ return integer;
17
+ },
15
18
  max: function() {
16
19
  return max;
17
20
  },
@@ -21,14 +24,8 @@ _export(exports, {
21
24
  min: function() {
22
25
  return min;
23
26
  },
24
- negative: function() {
25
- return negative;
26
- },
27
27
  numberValidation: function() {
28
28
  return numberValidation;
29
- },
30
- positive: function() {
31
- return positive;
32
29
  }
33
30
  });
34
31
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -161,6 +158,7 @@ function _ts_generator(thisArg, body) {
161
158
  }
162
159
  function numberValidation() {
163
160
  return {
161
+ name: 'number',
164
162
  type: 'medium',
165
163
  // eslint-disable-next-line ts/require-await
166
164
  callback: function() {
@@ -191,6 +189,7 @@ function numberValidation() {
191
189
  }
192
190
  function max(args) {
193
191
  return {
192
+ name: 'max',
194
193
  type: 'low',
195
194
  // eslint-disable-next-line ts/require-await
196
195
  callback: function() {
@@ -236,6 +235,7 @@ function max(args) {
236
235
  }
237
236
  function min(args) {
238
237
  return {
238
+ name: 'min',
239
239
  type: 'low',
240
240
  // eslint-disable-next-line ts/require-await
241
241
  callback: function() {
@@ -277,46 +277,16 @@ function min(args) {
277
277
  }()
278
278
  };
279
279
  }
280
- function negative(args) {
281
- return {
282
- type: 'low',
283
- // eslint-disable-next-line ts/require-await
284
- callback: function() {
285
- var _ref = _async_to_generator(function(value, path) {
286
- var isValid;
287
- return _ts_generator(this, function(_state) {
288
- isValid = args.allowZero ? value < 0 : value <= 0;
289
- return [
290
- 2,
291
- {
292
- parsed: value,
293
- errors: isValid ? [] : [
294
- {
295
- isValid: isValid,
296
- message: args.message,
297
- code: 'negative',
298
- path: path || []
299
- }
300
- ]
301
- }
302
- ];
303
- });
304
- });
305
- return function(value, path) {
306
- return _ref.apply(this, arguments);
307
- };
308
- }()
309
- };
310
- }
311
- function positive(args) {
280
+ function integer(args) {
312
281
  return {
282
+ name: 'integer',
313
283
  type: 'low',
314
284
  // eslint-disable-next-line ts/require-await
315
285
  callback: function() {
316
286
  var _ref = _async_to_generator(function(value, path) {
317
287
  var isValid;
318
288
  return _ts_generator(this, function(_state) {
319
- isValid = args.allowZero ? value > 0 : value >= 0;
289
+ isValid = Number.isInteger(value);
320
290
  return [
321
291
  2,
322
292
  {
@@ -325,7 +295,7 @@ function positive(args) {
325
295
  {
326
296
  isValid: isValid,
327
297
  message: args.message,
328
- code: 'positive',
298
+ code: 'integer',
329
299
  path: path || []
330
300
  }
331
301
  ]
@@ -341,6 +311,7 @@ function positive(args) {
341
311
  }
342
312
  function maxDigits(args) {
343
313
  return {
314
+ name: 'maxDigits',
344
315
  type: 'low',
345
316
  // eslint-disable-next-line ts/require-await
346
317
  callback: function() {
@@ -372,6 +343,7 @@ function maxDigits(args) {
372
343
  }
373
344
  function decimalPlaces(args) {
374
345
  return {
346
+ name: 'decimalPlaces',
375
347
  type: 'low',
376
348
  // eslint-disable-next-line ts/require-await
377
349
  callback: function() {
@@ -196,6 +196,7 @@ function _ts_generator(thisArg, body) {
196
196
  }
197
197
  function objectValidation(keysToFallback) {
198
198
  return {
199
+ name: 'object',
199
200
  type: 'low',
200
201
  callback: function() {
201
202
  var _ref = _async_to_generator(function(value, path, options) {
@@ -148,6 +148,7 @@ function _ts_generator(thisArg, body) {
148
148
  }
149
149
  function optional(args) {
150
150
  return {
151
+ name: 'optional',
151
152
  type: 'high',
152
153
  // eslint-disable-next-line ts/require-await
153
154
  callback: function() {
@@ -197,6 +198,7 @@ function optional(args) {
197
198
  }
198
199
  function nullable(args) {
199
200
  return {
201
+ name: 'nullable',
200
202
  type: 'high',
201
203
  // eslint-disable-next-line ts/require-await
202
204
  callback: function() {
@@ -219,7 +221,7 @@ function nullable(args) {
219
221
  {
220
222
  isValid: false,
221
223
  message: args.message,
222
- code: 'cannot_be_null',
224
+ code: 'null',
223
225
  // eslint-disable-next-line ts/no-unnecessary-condition
224
226
  path: path || []
225
227
  }
@@ -246,6 +248,7 @@ function nullable(args) {
246
248
  }
247
249
  function checkType(args) {
248
250
  return {
251
+ name: 'checkType',
249
252
  type: 'medium',
250
253
  // eslint-disable-next-line ts/require-await
251
254
  callback: function() {
@@ -285,6 +288,7 @@ function checkType(args) {
285
288
  }
286
289
  function is(args) {
287
290
  return {
291
+ name: 'is',
288
292
  type: 'medium',
289
293
  // eslint-disable-next-line ts/require-await
290
294
  callback: function() {
@@ -167,7 +167,9 @@ function _ts_generator(thisArg, body) {
167
167
  }
168
168
  function stringValidation() {
169
169
  return {
170
+ name: 'string',
170
171
  type: 'medium',
172
+ // eslint-disable-next-line ts/require-await
171
173
  callback: function() {
172
174
  var _ref = _async_to_generator(function(value, path, _options) {
173
175
  return _ts_generator(this, function(_state) {
@@ -179,6 +181,7 @@ function stringValidation() {
179
181
  {
180
182
  isValid: typeof value === 'string',
181
183
  code: 'string',
184
+ // eslint-disable-next-line ts/no-unnecessary-condition
182
185
  path: path || [],
183
186
  message: 'The value must be a string. Received: ' + (typeof value === "undefined" ? "undefined" : _type_of(value))
184
187
  }
@@ -195,12 +198,14 @@ function stringValidation() {
195
198
  }
196
199
  function maxLength(args) {
197
200
  return {
201
+ name: 'maxLength',
198
202
  type: 'low',
203
+ // eslint-disable-next-line ts/require-await
199
204
  callback: function() {
200
205
  var _ref = _async_to_generator(function(value, path, _options) {
201
206
  var isValid;
202
207
  return _ts_generator(this, function(_state) {
203
- isValid = args.inclusive ? value.length <= args.value : value.length < args.value;
208
+ isValid = value.length <= args.value;
204
209
  return [
205
210
  2,
206
211
  {
@@ -209,6 +214,7 @@ function maxLength(args) {
209
214
  {
210
215
  isValid: false,
211
216
  code: 'maxLength',
217
+ // eslint-disable-next-line ts/no-unnecessary-condition
212
218
  path: path || [],
213
219
  message: args.message
214
220
  }
@@ -225,12 +231,14 @@ function maxLength(args) {
225
231
  }
226
232
  function minLength(args) {
227
233
  return {
234
+ name: 'minLength',
228
235
  type: 'low',
236
+ // eslint-disable-next-line ts/require-await
229
237
  callback: function() {
230
238
  var _ref = _async_to_generator(function(value, path, _options) {
231
239
  var isValid;
232
240
  return _ts_generator(this, function(_state) {
233
- isValid = args.inclusive ? value.length >= args.value : value.length > args.value;
241
+ isValid = value.length >= args.value;
234
242
  return [
235
243
  2,
236
244
  {
@@ -239,6 +247,7 @@ function minLength(args) {
239
247
  {
240
248
  isValid: false,
241
249
  code: 'minLength',
250
+ // eslint-disable-next-line ts/no-unnecessary-condition
242
251
  path: path || [],
243
252
  message: args.message
244
253
  }
@@ -255,7 +264,9 @@ function minLength(args) {
255
264
  }
256
265
  function endsWith(args) {
257
266
  return {
267
+ name: 'endsWith',
258
268
  type: 'low',
269
+ // eslint-disable-next-line ts/require-await
259
270
  callback: function() {
260
271
  var _ref = _async_to_generator(function(value, path, _options) {
261
272
  var isValid;
@@ -269,6 +280,7 @@ function endsWith(args) {
269
280
  {
270
281
  isValid: false,
271
282
  code: 'endsWith',
283
+ // eslint-disable-next-line ts/no-unnecessary-condition
272
284
  path: path || [],
273
285
  message: args.message
274
286
  }
@@ -285,7 +297,9 @@ function endsWith(args) {
285
297
  }
286
298
  function startsWith(args) {
287
299
  return {
300
+ name: 'startsWith',
288
301
  type: 'low',
302
+ // eslint-disable-next-line ts/require-await
289
303
  callback: function() {
290
304
  var _ref = _async_to_generator(function(value, path, _options) {
291
305
  var isValid;
@@ -299,6 +313,7 @@ function startsWith(args) {
299
313
  {
300
314
  isValid: false,
301
315
  code: 'startsWith',
316
+ // eslint-disable-next-line ts/no-unnecessary-condition
302
317
  path: path || [],
303
318
  message: args.message
304
319
  }
@@ -315,7 +330,9 @@ function startsWith(args) {
315
330
  }
316
331
  function includes(args) {
317
332
  return {
333
+ name: 'includes',
318
334
  type: 'low',
335
+ // eslint-disable-next-line ts/require-await
319
336
  callback: function() {
320
337
  var _ref = _async_to_generator(function(value, path, _options) {
321
338
  var isValid;
@@ -329,6 +346,7 @@ function includes(args) {
329
346
  {
330
347
  isValid: false,
331
348
  code: 'includes',
349
+ // eslint-disable-next-line ts/no-unnecessary-condition
332
350
  path: path || [],
333
351
  message: args.message
334
352
  }
@@ -345,7 +363,9 @@ function includes(args) {
345
363
  }
346
364
  function regex(args) {
347
365
  return {
366
+ name: 'regex',
348
367
  type: 'low',
368
+ // eslint-disable-next-line ts/require-await
349
369
  callback: function() {
350
370
  var _ref = _async_to_generator(function(value, path, _options) {
351
371
  var isValid;
@@ -359,6 +379,7 @@ function regex(args) {
359
379
  {
360
380
  isValid: false,
361
381
  code: 'regex',
382
+ // eslint-disable-next-line ts/no-unnecessary-condition
362
383
  path: path || [],
363
384
  message: args.message
364
385
  }
@@ -378,7 +399,9 @@ function uuid(args) {
378
399
  // /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
379
400
  var uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
380
401
  return {
402
+ name: 'uuid',
381
403
  type: 'low',
404
+ // eslint-disable-next-line ts/require-await
382
405
  callback: function() {
383
406
  var _ref = _async_to_generator(function(value, path, _options) {
384
407
  var isValid;
@@ -392,6 +415,7 @@ function uuid(args) {
392
415
  {
393
416
  isValid: false,
394
417
  code: 'uuid',
418
+ // eslint-disable-next-line ts/no-unnecessary-condition
395
419
  path: path || [],
396
420
  message: args.message
397
421
  }
@@ -408,8 +432,11 @@ function uuid(args) {
408
432
  }
409
433
  function email(args) {
410
434
  var emailRegex = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
435
+ console.log('aquiiiiii');
411
436
  return {
437
+ name: 'email',
412
438
  type: 'low',
439
+ // eslint-disable-next-line ts/require-await
413
440
  callback: function() {
414
441
  var _ref = _async_to_generator(function(value, path, _options) {
415
442
  var isValid;
@@ -423,6 +450,7 @@ function email(args) {
423
450
  {
424
451
  isValid: false,
425
452
  code: 'email',
453
+ // eslint-disable-next-line ts/no-unnecessary-condition
426
454
  path: path || [],
427
455
  message: args.message
428
456
  }
@@ -159,7 +159,8 @@ function _ts_generator(thisArg, body) {
159
159
  }
160
160
  function unionValidation(schemas) {
161
161
  return {
162
- type: 'high',
162
+ name: 'union',
163
+ type: 'medium',
163
164
  callback: function() {
164
165
  var _ref = _async_to_generator(function(value, path, options) {
165
166
  var _options_toInternalToBubbleUp, parsedValues, startingToInternalBubbleUpLength, i, _parsedValues_errors, _options_toInternalToBubbleUp1, schemaWithProtected, parsedData, hasNoErrorsSoItsAValidSchemaAndShouldResetOldErrors, _options_toInternalToBubbleUp2, _options_toInternalToBubbleUp3, numberOfElementsToRemove;
@@ -200,8 +201,8 @@ function unionValidation(schemas) {
200
201
  ];
201
202
  } else if (startingToInternalBubbleUpLength < (((_options_toInternalToBubbleUp1 = options.toInternalToBubbleUp) === null || _options_toInternalToBubbleUp1 === void 0 ? void 0 : _options_toInternalToBubbleUp1.length) || 0)) {
202
203
  ;
203
- // If there is a new toInternalToBubbleUp we should remove the ones that we added since this is not a valid schema,
204
- // we shouldn't be calling the `toInternal` on that schemas.
204
+ // If there is a new toInternalToBubbleUp we should remove the ones that we added since this is not a
205
+ // valid schema, we shouldn't be calling the `toInternal` on that schemas.
205
206
  numberOfElementsToRemove = (((_options_toInternalToBubbleUp2 = options.toInternalToBubbleUp) === null || _options_toInternalToBubbleUp2 === void 0 ? void 0 : _options_toInternalToBubbleUp2.length) || 0) - startingToInternalBubbleUpLength;
206
207
  (_options_toInternalToBubbleUp3 = options.toInternalToBubbleUp) === null || _options_toInternalToBubbleUp3 === void 0 ? void 0 : _options_toInternalToBubbleUp3.splice(startingToInternalBubbleUpLength, numberOfElementsToRemove);
207
208
  }
@@ -218,7 +219,7 @@ function unionValidation(schemas) {
218
219
  {
219
220
  parsed: parsedValues.parsed,
220
221
  // eslint-disable-next-line ts/no-unnecessary-condition
221
- errors: parsedValues.errors ? parsedValues.errors : []
222
+ errors: Array.isArray(parsedValues.errors) ? parsedValues.errors : []
222
223
  }
223
224
  ];
224
225
  }