@palmares/schemas 0.0.1 → 0.1.1
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.
- package/.turbo/turbo-build$colon$watch.log +12 -410
- package/.turbo/turbo-build.log +13 -4
- package/CHANGELOG.md +26 -0
- package/__tests__/.drizzle/migrations/0000_skinny_harrier.sql +22 -0
- package/__tests__/.drizzle/migrations/meta/0000_snapshot.json +156 -0
- package/__tests__/.drizzle/migrations/meta/_journal.json +13 -0
- package/__tests__/.drizzle/schema.ts +35 -0
- package/__tests__/drizzle.config.ts +11 -0
- package/__tests__/eslint.config.js +10 -0
- package/__tests__/manage.ts +5 -0
- package/__tests__/node_modules/.bin/drizzle-kit +17 -0
- package/__tests__/node_modules/.bin/esbuild +14 -0
- package/__tests__/node_modules/.bin/tsc +17 -0
- package/__tests__/node_modules/.bin/tsserver +17 -0
- package/__tests__/node_modules/.bin/tsx +17 -0
- package/__tests__/package.json +36 -0
- package/__tests__/sqlite.db +0 -0
- package/__tests__/src/core/array.test.ts +130 -0
- package/__tests__/src/core/boolean.test.ts +66 -0
- package/__tests__/src/core/datetime.test.ts +102 -0
- package/__tests__/src/core/index.ts +35 -0
- package/__tests__/src/core/model.test.ts +260 -0
- package/__tests__/src/core/models.ts +50 -0
- package/__tests__/src/core/numbers.test.ts +177 -0
- package/__tests__/src/core/object.test.ts +198 -0
- package/__tests__/src/core/string.test.ts +222 -0
- package/__tests__/src/core/test.test.ts +59 -0
- package/__tests__/src/core/types.test.ts +97 -0
- package/__tests__/src/core/union.test.ts +99 -0
- package/__tests__/src/settings.ts +71 -0
- package/__tests__/tsconfig.json +11 -0
- package/dist/cjs/src/adapter/fields/index.js +2 -2
- package/dist/cjs/src/adapter/fields/object.js +9 -0
- package/dist/cjs/src/adapter/index.js +1 -0
- package/dist/cjs/src/constants.js +1 -7
- package/dist/cjs/src/domain.js +146 -1
- package/dist/cjs/src/index.js +69 -74
- package/dist/cjs/src/model.js +206 -206
- package/dist/cjs/src/schema/array.js +185 -58
- package/dist/cjs/src/schema/boolean.js +105 -44
- package/dist/cjs/src/schema/datetime.js +104 -38
- package/dist/cjs/src/schema/number.js +134 -114
- package/dist/cjs/src/schema/object.js +106 -43
- package/dist/cjs/src/schema/schema.js +123 -75
- package/dist/cjs/src/schema/string.js +152 -58
- package/dist/cjs/src/schema/union.js +412 -290
- package/dist/cjs/src/utils.js +42 -15
- package/dist/cjs/src/validators/array.js +6 -1
- package/dist/cjs/src/validators/boolean.js +2 -0
- package/dist/cjs/src/validators/datetime.js +4 -0
- package/dist/cjs/src/validators/number.js +12 -40
- package/dist/cjs/src/validators/object.js +1 -0
- package/dist/cjs/src/validators/schema.js +5 -1
- package/dist/cjs/src/validators/string.js +30 -2
- package/dist/cjs/src/validators/union.js +5 -4
- package/dist/cjs/src/validators/utils.js +99 -27
- package/dist/cjs/tsconfig.types.tsbuildinfo +1 -1
- package/dist/cjs/types/adapter/fields/array.d.ts +2 -2
- package/dist/cjs/types/adapter/fields/array.d.ts.map +1 -1
- package/dist/cjs/types/adapter/fields/boolean.d.ts.map +1 -1
- package/dist/cjs/types/adapter/fields/datetime.d.ts.map +1 -1
- package/dist/cjs/types/adapter/fields/index.d.ts +2 -2
- package/dist/cjs/types/adapter/fields/index.d.ts.map +1 -1
- package/dist/cjs/types/adapter/fields/number.d.ts.map +1 -1
- package/dist/cjs/types/adapter/fields/object.d.ts +2 -1
- package/dist/cjs/types/adapter/fields/object.d.ts.map +1 -1
- package/dist/cjs/types/adapter/fields/string.d.ts.map +1 -1
- package/dist/cjs/types/adapter/fields/union.d.ts.map +1 -1
- package/dist/cjs/types/adapter/index.d.ts +1 -0
- package/dist/cjs/types/adapter/index.d.ts.map +1 -1
- package/dist/cjs/types/adapter/types.d.ts +28 -18
- package/dist/cjs/types/adapter/types.d.ts.map +1 -1
- package/dist/cjs/types/constants.d.ts +0 -1
- package/dist/cjs/types/constants.d.ts.map +1 -1
- package/dist/cjs/types/domain.d.ts +5 -4
- package/dist/cjs/types/domain.d.ts.map +1 -1
- package/dist/cjs/types/index.d.ts +78 -55
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/types/model.d.ts +17 -17
- package/dist/cjs/types/model.d.ts.map +1 -1
- package/dist/cjs/types/schema/array.d.ts +168 -47
- package/dist/cjs/types/schema/array.d.ts.map +1 -1
- package/dist/cjs/types/schema/boolean.d.ts +103 -44
- package/dist/cjs/types/schema/boolean.d.ts.map +1 -1
- package/dist/cjs/types/schema/datetime.d.ts +90 -30
- package/dist/cjs/types/schema/datetime.d.ts.map +1 -1
- package/dist/cjs/types/schema/number.d.ts +133 -125
- package/dist/cjs/types/schema/number.d.ts.map +1 -1
- package/dist/cjs/types/schema/object.d.ts +104 -35
- package/dist/cjs/types/schema/object.d.ts.map +1 -1
- package/dist/cjs/types/schema/schema.d.ts +62 -44
- package/dist/cjs/types/schema/schema.d.ts.map +1 -1
- package/dist/cjs/types/schema/string.d.ts +152 -65
- package/dist/cjs/types/schema/string.d.ts.map +1 -1
- package/dist/cjs/types/schema/types.d.ts +11 -2
- package/dist/cjs/types/schema/types.d.ts.map +1 -1
- package/dist/cjs/types/schema/union.d.ts +133 -40
- package/dist/cjs/types/schema/union.d.ts.map +1 -1
- package/dist/cjs/types/types.d.ts +35 -0
- package/dist/cjs/types/types.d.ts.map +1 -1
- package/dist/cjs/types/utils.d.ts +41 -27
- package/dist/cjs/types/utils.d.ts.map +1 -1
- package/dist/cjs/types/validators/array.d.ts.map +1 -1
- package/dist/cjs/types/validators/boolean.d.ts.map +1 -1
- package/dist/cjs/types/validators/datetime.d.ts.map +1 -1
- package/dist/cjs/types/validators/number.d.ts +5 -6
- package/dist/cjs/types/validators/number.d.ts.map +1 -1
- package/dist/cjs/types/validators/object.d.ts.map +1 -1
- package/dist/cjs/types/validators/schema.d.ts +2 -2
- package/dist/cjs/types/validators/schema.d.ts.map +1 -1
- package/dist/cjs/types/validators/string.d.ts +9 -9
- package/dist/cjs/types/validators/string.d.ts.map +1 -1
- package/dist/cjs/types/validators/utils.d.ts +44 -27
- package/dist/cjs/types/validators/utils.d.ts.map +1 -1
- package/dist/esm/src/adapter/fields/index.js +2 -2
- package/dist/esm/src/adapter/fields/object.js +6 -0
- package/dist/esm/src/adapter/index.js +1 -0
- package/dist/esm/src/constants.js +1 -2
- package/dist/esm/src/domain.js +11 -1
- package/dist/esm/src/index.js +38 -73
- package/dist/esm/src/model.js +83 -78
- package/dist/esm/src/schema/array.js +136 -54
- package/dist/esm/src/schema/boolean.js +98 -44
- package/dist/esm/src/schema/datetime.js +91 -38
- package/dist/esm/src/schema/number.js +127 -110
- package/dist/esm/src/schema/object.js +98 -43
- package/dist/esm/src/schema/schema.js +102 -67
- package/dist/esm/src/schema/string.js +147 -59
- package/dist/esm/src/schema/union.js +119 -40
- package/dist/esm/src/types.js +14 -1
- package/dist/esm/src/utils.js +56 -27
- package/dist/esm/src/validators/array.js +6 -1
- package/dist/esm/src/validators/boolean.js +2 -0
- package/dist/esm/src/validators/datetime.js +4 -0
- package/dist/esm/src/validators/number.js +9 -23
- package/dist/esm/src/validators/object.js +1 -0
- package/dist/esm/src/validators/schema.js +5 -1
- package/dist/esm/src/validators/string.js +30 -2
- package/dist/esm/src/validators/union.js +5 -4
- package/dist/esm/src/validators/utils.js +62 -36
- package/package.json +3 -3
- package/src/adapter/fields/array.ts +2 -2
- package/src/adapter/fields/boolean.ts +3 -8
- package/src/adapter/fields/datetime.ts +3 -9
- package/src/adapter/fields/index.ts +11 -11
- package/src/adapter/fields/number.ts +3 -9
- package/src/adapter/fields/object.ts +13 -10
- package/src/adapter/fields/string.ts +3 -9
- package/src/adapter/fields/union.ts +3 -9
- package/src/adapter/index.ts +1 -0
- package/src/adapter/types.ts +60 -45
- package/src/constants.ts +1 -3
- package/src/domain.ts +15 -1
- package/src/index.ts +189 -211
- package/src/model.ts +119 -115
- package/src/schema/array.ts +274 -90
- package/src/schema/boolean.ts +145 -60
- package/src/schema/datetime.ts +133 -49
- package/src/schema/number.ts +210 -173
- package/src/schema/object.ts +167 -74
- package/src/schema/schema.ts +205 -126
- package/src/schema/string.ts +221 -94
- package/src/schema/types.ts +44 -16
- package/src/schema/union.ts +193 -68
- package/src/types.ts +53 -0
- package/src/utils.ts +115 -57
- package/src/validators/array.ts +46 -27
- package/src/validators/boolean.ts +13 -7
- package/src/validators/datetime.ts +24 -16
- package/src/validators/number.ts +53 -63
- package/src/validators/object.ts +6 -5
- package/src/validators/schema.ts +33 -25
- package/src/validators/string.ts +122 -59
- package/src/validators/union.ts +8 -8
- package/src/validators/utils.ts +67 -42
@@ -17,7 +17,6 @@ _export(exports, {
|
|
17
17
|
}
|
18
18
|
});
|
19
19
|
var _schema = /*#__PURE__*/ _interop_require_default(require("./schema"));
|
20
|
-
var _conf = require("../conf");
|
21
20
|
var _utils = require("../utils");
|
22
21
|
var _object = require("../validators/object");
|
23
22
|
var _utils1 = /*#__PURE__*/ _interop_require_default(require("../validators/utils"));
|
@@ -349,6 +348,12 @@ var ObjectSchema = /*#__PURE__*/ function(Schema) {
|
|
349
348
|
_this = _super.call(this);
|
350
349
|
_define_property(_assert_this_initialized(_this), "__data", void 0);
|
351
350
|
_define_property(_assert_this_initialized(_this), "__cachedDataAsEntries", void 0);
|
351
|
+
_define_property(_assert_this_initialized(_this), "__type", {
|
352
|
+
message: 'Invalid type',
|
353
|
+
check: function(value) {
|
354
|
+
return (typeof value === "undefined" ? "undefined" : _type_of(value)) === 'object' && value !== null;
|
355
|
+
}
|
356
|
+
});
|
352
357
|
_this.__data = data;
|
353
358
|
return _this;
|
354
359
|
}
|
@@ -468,6 +473,7 @@ var ObjectSchema = /*#__PURE__*/ function(Schema) {
|
|
468
473
|
data: isStringVersion ? asString : transformed,
|
469
474
|
nullable: _this.__nullable,
|
470
475
|
optional: _this.__optional,
|
476
|
+
type: _this.__type,
|
471
477
|
parsers: {
|
472
478
|
nullable: _this.__nullable.allow,
|
473
479
|
optional: _this.__optional.allow
|
@@ -489,7 +495,7 @@ var ObjectSchema = /*#__PURE__*/ function(Schema) {
|
|
489
495
|
return function(adapter) {
|
490
496
|
return _ref.apply(this, arguments);
|
491
497
|
};
|
492
|
-
}(), _this.__transformedSchemas, options, 'object')
|
498
|
+
}(), _this, _this.__transformedSchemas, options, 'object')
|
493
499
|
];
|
494
500
|
});
|
495
501
|
})();
|
@@ -498,8 +504,10 @@ var ObjectSchema = /*#__PURE__*/ function(Schema) {
|
|
498
504
|
{
|
499
505
|
key: "data",
|
500
506
|
value: /**
|
501
|
-
* Transform the data to the representation without validating it. This is useful when you want to return a data
|
502
|
-
* from
|
507
|
+
* Transform the data to the representation without validating it. This is useful when you want to return a data
|
508
|
+
* from a query directly to the user. The core idea of this is that you can join the data from the database "by hand".
|
509
|
+
* In other words, you can do the joins by yourself directly on code. For more complex cases, this can be really
|
510
|
+
* helpful.
|
503
511
|
*
|
504
512
|
* @param value - The value to be transformed.
|
505
513
|
*
|
@@ -575,7 +583,8 @@ var ObjectSchema = /*#__PURE__*/ function(Schema) {
|
|
575
583
|
},
|
576
584
|
{
|
577
585
|
/**
|
578
|
-
* This let's you refine the schema with custom validations. This is useful when you want to validate something
|
586
|
+
* This let's you refine the schema with custom validations. This is useful when you want to validate something
|
587
|
+
* that is not supported by default by the schema adapter.
|
579
588
|
*
|
580
589
|
* @example
|
581
590
|
* ```typescript
|
@@ -587,7 +596,8 @@ var ObjectSchema = /*#__PURE__*/ function(Schema) {
|
|
587
596
|
*
|
588
597
|
* const { errors, parsed } = await numberSchema.parse(-1);
|
589
598
|
*
|
590
|
-
*
|
599
|
+
* // [{ isValid: false, code: 'invalid_number', message: 'The number should be greater than 0', path: [] }]
|
600
|
+
* console.log(errors);
|
591
601
|
* ```
|
592
602
|
*
|
593
603
|
* @param refinementCallback - The callback that will be called to validate the value.
|
@@ -600,9 +610,10 @@ var ObjectSchema = /*#__PURE__*/ function(Schema) {
|
|
600
610
|
},
|
601
611
|
{
|
602
612
|
/**
|
603
|
-
* Allows the value to be either undefined or null. Different from the `optional` method on other schemas, You can
|
604
|
-
* This will allow you to pass `null` or `undefined` as a value on the
|
605
|
-
* This is useful for
|
613
|
+
* Allows the value to be either undefined or null. Different from the `optional` method on other schemas, You can
|
614
|
+
* pass `outputOnly` as `true` to this method. This will allow you to pass `null` or `undefined` as a value on the
|
615
|
+
* {@link Schema.data} method, but it will not allow the value to be `null` or `undefined`. This is useful for
|
616
|
+
* typing purposes
|
606
617
|
*
|
607
618
|
* @example
|
608
619
|
* ```typescript
|
@@ -630,8 +641,11 @@ var ObjectSchema = /*#__PURE__*/ function(Schema) {
|
|
630
641
|
* company: companySchema.optional({ outputOnly: true })
|
631
642
|
* });
|
632
643
|
*
|
633
|
-
*
|
634
|
-
* const
|
644
|
+
* // Will not allow the company to be null or undefined on a typing level.
|
645
|
+
* const { errors, parsed } = await userSchema.data({ id: 1, name: 'John Doe' });
|
646
|
+
*
|
647
|
+
* // Will allow the company to be null or undefined on a typing level
|
648
|
+
* const value = await userSchema.data({ id: 1, name: 'John Doe' });
|
635
649
|
* ```
|
636
650
|
*
|
637
651
|
* @returns - The schema we are working with.
|
@@ -642,7 +656,28 @@ var ObjectSchema = /*#__PURE__*/ function(Schema) {
|
|
642
656
|
},
|
643
657
|
{
|
644
658
|
/**
|
645
|
-
*
|
659
|
+
* Just adds a message when the value is undefined. It's just a syntax sugar for
|
660
|
+
*
|
661
|
+
* ```typescript
|
662
|
+
* p.datetime().optional({ message: 'This value should be defined', allow: false })
|
663
|
+
* ```
|
664
|
+
*
|
665
|
+
* @param options - The options of nonOptional function
|
666
|
+
* @param options.message - A custom message if the value is undefined.
|
667
|
+
*
|
668
|
+
* @returns - The schema.
|
669
|
+
*/ key: "nonOptional",
|
670
|
+
value: function nonOptional(options) {
|
671
|
+
return _get(_get_prototype_of(ObjectSchema.prototype), "optional", this).call(this, {
|
672
|
+
message: options === null || options === void 0 ? void 0 : options.message,
|
673
|
+
allow: false
|
674
|
+
});
|
675
|
+
}
|
676
|
+
},
|
677
|
+
{
|
678
|
+
/**
|
679
|
+
* Allows the value to be null and ONLY null. You can also use this function to set a custom message when the value
|
680
|
+
* is NULL by setting
|
646
681
|
* the { message: 'Your custom message', allow: false } on the options.
|
647
682
|
*
|
648
683
|
* @example
|
@@ -672,14 +707,37 @@ var ObjectSchema = /*#__PURE__*/ function(Schema) {
|
|
672
707
|
},
|
673
708
|
{
|
674
709
|
/**
|
675
|
-
*
|
676
|
-
*
|
710
|
+
* Just adds a message when the value is null. It's just a syntax sugar for
|
711
|
+
*
|
712
|
+
* ```typescript
|
713
|
+
* p.datetime().nullable({ message: 'This value cannot be null', allow: false })
|
714
|
+
* ```
|
715
|
+
*
|
716
|
+
* @param options - The options of nonNullable function
|
717
|
+
* @param options.message - A custom message if the value is null.
|
718
|
+
*
|
719
|
+
* @returns - The schema.
|
720
|
+
*/ key: "nonNullable",
|
721
|
+
value: function nonNullable(options) {
|
722
|
+
return _get(_get_prototype_of(ObjectSchema.prototype), "nullable", this).call(this, {
|
723
|
+
message: (options === null || options === void 0 ? void 0 : options.message) || '',
|
724
|
+
allow: false
|
725
|
+
});
|
726
|
+
}
|
727
|
+
},
|
728
|
+
{
|
729
|
+
/**
|
730
|
+
* This method will remove the value from the representation of the schema. If the value is undefined it will keep
|
731
|
+
* that way otherwise it will set the value to undefined after it's validated.
|
677
732
|
* This is used in conjunction with the {@link data} function, the {@link parse} function or {@link validate}
|
678
733
|
* function. This will remove the value from the representation of the schema.
|
679
734
|
*
|
680
|
-
* By default, the value will be removed just from the representation, in other words, when you call the {@link data}
|
681
|
-
*
|
682
|
-
*
|
735
|
+
* By default, the value will be removed just from the representation, in other words, when you call the {@link data}
|
736
|
+
* function.
|
737
|
+
* But if you want to remove the value from the internal representation, you can pass the argument `toInternal`
|
738
|
+
* as true.
|
739
|
+
* Then if you still want to remove the value from the representation, you will need to pass the argument
|
740
|
+
* `toRepresentation` as true as well.
|
683
741
|
*
|
684
742
|
* @example
|
685
743
|
* ```typescript
|
@@ -701,9 +759,12 @@ var ObjectSchema = /*#__PURE__*/ function(Schema) {
|
|
701
759
|
* ```
|
702
760
|
*
|
703
761
|
*
|
704
|
-
* @param args - By default, the value will be removed just from the representation, in other words, when you call
|
705
|
-
*
|
706
|
-
*
|
762
|
+
* @param args - By default, the value will be removed just from the representation, in other words, when you call
|
763
|
+
* the {@link data} function.
|
764
|
+
* But if you want to remove the value from the internal representation, you can pass the argument `toInternal`
|
765
|
+
* as true.
|
766
|
+
* Then if you still want to remove the value from the representation, you will need to pass the argument
|
767
|
+
* `toRepresentation` as true as well.
|
707
768
|
*
|
708
769
|
* @returns The schema.
|
709
770
|
*/ key: "omit",
|
@@ -713,9 +774,9 @@ var ObjectSchema = /*#__PURE__*/ function(Schema) {
|
|
713
774
|
},
|
714
775
|
{
|
715
776
|
/**
|
716
|
-
* This function is used in conjunction with the {@link validate} function. It's used to save a value to an external
|
717
|
-
* like a database. You should always return the schema after you save the value, that way we will always have
|
718
|
-
* of the schema after the save operation.
|
777
|
+
* This function is used in conjunction with the {@link validate} function. It's used to save a value to an external
|
778
|
+
* source like a database. You should always return the schema after you save the value, that way we will always have
|
779
|
+
* the correct type of the schema after the save operation.
|
719
780
|
*
|
720
781
|
* You can use the {@link toRepresentation} function to transform and clean the value it returns after the save.
|
721
782
|
*
|
@@ -760,7 +821,8 @@ var ObjectSchema = /*#__PURE__*/ function(Schema) {
|
|
760
821
|
},
|
761
822
|
{
|
762
823
|
/**
|
763
|
-
* This function is used to add a default value to the schema. If the value is either undefined or null, the default
|
824
|
+
* This function is used to add a default value to the schema. If the value is either undefined or null, the default
|
825
|
+
* value will be used.
|
764
826
|
*
|
765
827
|
* @example
|
766
828
|
* ```typescript
|
@@ -779,8 +841,9 @@ var ObjectSchema = /*#__PURE__*/ function(Schema) {
|
|
779
841
|
},
|
780
842
|
{
|
781
843
|
/**
|
782
|
-
* This function let's you customize the schema your own way. After we translate the schema on the adapter we call
|
783
|
-
* the custom schema your own way. Our API does not support passthrough?
|
844
|
+
* This function let's you customize the schema your own way. After we translate the schema on the adapter we call
|
845
|
+
* this function to let you customize the custom schema your own way. Our API does not support passthrough?
|
846
|
+
* No problem, you can use this function to customize the zod schema.
|
784
847
|
*
|
785
848
|
* @example
|
786
849
|
* ```typescript
|
@@ -792,12 +855,13 @@ var ObjectSchema = /*#__PURE__*/ function(Schema) {
|
|
792
855
|
*
|
793
856
|
* const { errors, parsed } = await numberSchema.parse(-1);
|
794
857
|
*
|
795
|
-
*
|
858
|
+
* // [{ isValid: false, code: 'nonnegative', message: 'The number should be nonnegative', path: [] }]
|
859
|
+
* console.log(errors);
|
796
860
|
* ```
|
797
861
|
*
|
798
862
|
* @param callback - The callback that will be called to customize the schema.
|
799
|
-
* @param toStringCallback - The callback that will be called to transform the schema to a string when you want to
|
800
|
-
* to a string so you can save it for future runs.
|
863
|
+
* @param toStringCallback - The callback that will be called to transform the schema to a string when you want to
|
864
|
+
* compile the underlying schema to a string so you can save it for future runs.
|
801
865
|
*
|
802
866
|
* @returns The schema.
|
803
867
|
*/ key: "extends",
|
@@ -807,8 +871,9 @@ var ObjectSchema = /*#__PURE__*/ function(Schema) {
|
|
807
871
|
},
|
808
872
|
{
|
809
873
|
/**
|
810
|
-
* This function is used to transform the value to the representation of the schema. When using the {@link data}
|
811
|
-
* control to add data cleaning for example, transforming the data and
|
874
|
+
* This function is used to transform the value to the representation of the schema. When using the {@link data}
|
875
|
+
* function. With this function you have full control to add data cleaning for example, transforming the data and
|
876
|
+
* whatever. Another use case is when you want to return deeply nested recursive data.
|
812
877
|
* The schema maps to itself.
|
813
878
|
*
|
814
879
|
* @example
|
@@ -847,8 +912,10 @@ var ObjectSchema = /*#__PURE__*/ function(Schema) {
|
|
847
912
|
* ```
|
848
913
|
* @param toRepresentationCallback - The callback that will be called to transform the value to the representation.
|
849
914
|
* @param options - Options for the toRepresentation function.
|
850
|
-
* @param options.after - Whether the toRepresentationCallback should be called after the existing
|
851
|
-
*
|
915
|
+
* @param options.after - Whether the toRepresentationCallback should be called after the existing
|
916
|
+
* toRepresentationCallback. Defaults to true.
|
917
|
+
* @param options.before - Whether the toRepresentationCallback should be called before the existing
|
918
|
+
* toRepresentationCallback. Defaults to true.
|
852
919
|
*
|
853
920
|
* @returns The schema with a new return type
|
854
921
|
*/ key: "toRepresentation",
|
@@ -858,8 +925,9 @@ var ObjectSchema = /*#__PURE__*/ function(Schema) {
|
|
858
925
|
},
|
859
926
|
{
|
860
927
|
/**
|
861
|
-
* This function is used to transform the value to the internal representation of the schema. This is useful when
|
862
|
-
* to a type that the schema adapter can understand. For example, you might want
|
928
|
+
* This function is used to transform the value to the internal representation of the schema. This is useful when
|
929
|
+
* you want to transform the value to a type that the schema adapter can understand. For example, you might want
|
930
|
+
* to transform a string to a date. This is the function you use.
|
863
931
|
*
|
864
932
|
* @example
|
865
933
|
* ```typescript
|
@@ -895,8 +963,9 @@ var ObjectSchema = /*#__PURE__*/ function(Schema) {
|
|
895
963
|
},
|
896
964
|
{
|
897
965
|
/**
|
898
|
-
* Called before the validation of the schema. Let's say that you want to validate a date that might receive a string,
|
899
|
-
* here BEFORE the validation. This pretty much transforms the value to a type
|
966
|
+
* Called before the validation of the schema. Let's say that you want to validate a date that might receive a string,
|
967
|
+
* you can convert that string to a date here BEFORE the validation. This pretty much transforms the value to a type
|
968
|
+
* that the schema adapter can understand.
|
900
969
|
*
|
901
970
|
* @example
|
902
971
|
* ```
|
@@ -984,12 +1053,6 @@ var ObjectSchema = /*#__PURE__*/ function(Schema) {
|
|
984
1053
|
key: "new",
|
985
1054
|
value: function _new(data) {
|
986
1055
|
var returnValue = new ObjectSchema(data);
|
987
|
-
var adapterInstance = (0, _conf.getDefaultAdapter)();
|
988
|
-
returnValue.__transformedSchemas[adapterInstance.constructor.name] = {
|
989
|
-
transformed: false,
|
990
|
-
adapter: adapterInstance,
|
991
|
-
schemas: []
|
992
|
-
};
|
993
1056
|
return returnValue;
|
994
1057
|
}
|
995
1058
|
}
|