@atscript/typescript 0.1.14 → 0.1.15
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/dist/cli.cjs +14 -3
- package/dist/index.cjs +14 -3
- package/dist/index.mjs +14 -3
- package/dist/utils.cjs +14 -3
- package/dist/utils.d.ts +1 -0
- package/dist/utils.mjs +14 -3
- package/package.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -733,7 +733,7 @@ else {
|
|
|
733
733
|
this.error(`Expected ${def.type.designType}, got ${typeOfValue}`);
|
|
734
734
|
return false;
|
|
735
735
|
}
|
|
736
|
-
return
|
|
736
|
+
return this.validateBoolean(def, value);
|
|
737
737
|
case "undefined":
|
|
738
738
|
if (value !== undefined) {
|
|
739
739
|
this.error(`Expected ${def.type.designType}, got ${typeOfValue}`);
|
|
@@ -750,7 +750,7 @@ else {
|
|
|
750
750
|
}
|
|
751
751
|
}
|
|
752
752
|
validateString(def, value) {
|
|
753
|
-
const filled = def.metadata.get("
|
|
753
|
+
const filled = def.metadata.get("meta.required");
|
|
754
754
|
if (filled) {
|
|
755
755
|
if (value.trim().length === 0) {
|
|
756
756
|
const message = typeof filled === "object" && filled.message ? filled.message : `Must not be empty`;
|
|
@@ -819,6 +819,17 @@ else {
|
|
|
819
819
|
}
|
|
820
820
|
return true;
|
|
821
821
|
}
|
|
822
|
+
validateBoolean(def, value) {
|
|
823
|
+
const filled = def.metadata.get("meta.required");
|
|
824
|
+
if (filled) {
|
|
825
|
+
if (value !== true) {
|
|
826
|
+
const message = typeof filled === "object" && filled.message ? filled.message : `Must be checked`;
|
|
827
|
+
this.error(message);
|
|
828
|
+
return false;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
return true;
|
|
832
|
+
}
|
|
822
833
|
constructor(def, opts) {
|
|
823
834
|
_define_property$2(this, "def", void 0);
|
|
824
835
|
_define_property$2(this, "opts", void 0);
|
|
@@ -1025,7 +1036,7 @@ function buildJsonSchema(type) {
|
|
|
1025
1036
|
if (schema.type === "number" && meta.get("expect.int")) schema.type = "integer";
|
|
1026
1037
|
}
|
|
1027
1038
|
if (schema.type === "string") {
|
|
1028
|
-
if (meta.get("
|
|
1039
|
+
if (meta.get("meta.required")) schema.minLength = 1;
|
|
1029
1040
|
const minLength = meta.get("expect.minLength");
|
|
1030
1041
|
if (minLength) schema.minLength = typeof minLength === "number" ? minLength : minLength.length;
|
|
1031
1042
|
const maxLength = meta.get("expect.maxLength");
|
package/dist/index.cjs
CHANGED
|
@@ -730,7 +730,7 @@ else {
|
|
|
730
730
|
this.error(`Expected ${def.type.designType}, got ${typeOfValue}`);
|
|
731
731
|
return false;
|
|
732
732
|
}
|
|
733
|
-
return
|
|
733
|
+
return this.validateBoolean(def, value);
|
|
734
734
|
case "undefined":
|
|
735
735
|
if (value !== undefined) {
|
|
736
736
|
this.error(`Expected ${def.type.designType}, got ${typeOfValue}`);
|
|
@@ -747,7 +747,7 @@ else {
|
|
|
747
747
|
}
|
|
748
748
|
}
|
|
749
749
|
validateString(def, value) {
|
|
750
|
-
const filled = def.metadata.get("
|
|
750
|
+
const filled = def.metadata.get("meta.required");
|
|
751
751
|
if (filled) {
|
|
752
752
|
if (value.trim().length === 0) {
|
|
753
753
|
const message = typeof filled === "object" && filled.message ? filled.message : `Must not be empty`;
|
|
@@ -816,6 +816,17 @@ else {
|
|
|
816
816
|
}
|
|
817
817
|
return true;
|
|
818
818
|
}
|
|
819
|
+
validateBoolean(def, value) {
|
|
820
|
+
const filled = def.metadata.get("meta.required");
|
|
821
|
+
if (filled) {
|
|
822
|
+
if (value !== true) {
|
|
823
|
+
const message = typeof filled === "object" && filled.message ? filled.message : `Must be checked`;
|
|
824
|
+
this.error(message);
|
|
825
|
+
return false;
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
return true;
|
|
829
|
+
}
|
|
819
830
|
constructor(def, opts) {
|
|
820
831
|
_define_property$1(this, "def", void 0);
|
|
821
832
|
_define_property$1(this, "opts", void 0);
|
|
@@ -1022,7 +1033,7 @@ function buildJsonSchema(type) {
|
|
|
1022
1033
|
if (schema.type === "number" && meta.get("expect.int")) schema.type = "integer";
|
|
1023
1034
|
}
|
|
1024
1035
|
if (schema.type === "string") {
|
|
1025
|
-
if (meta.get("
|
|
1036
|
+
if (meta.get("meta.required")) schema.minLength = 1;
|
|
1026
1037
|
const minLength = meta.get("expect.minLength");
|
|
1027
1038
|
if (minLength) schema.minLength = typeof minLength === "number" ? minLength : minLength.length;
|
|
1028
1039
|
const maxLength = meta.get("expect.maxLength");
|
package/dist/index.mjs
CHANGED
|
@@ -706,7 +706,7 @@ else {
|
|
|
706
706
|
this.error(`Expected ${def.type.designType}, got ${typeOfValue}`);
|
|
707
707
|
return false;
|
|
708
708
|
}
|
|
709
|
-
return
|
|
709
|
+
return this.validateBoolean(def, value);
|
|
710
710
|
case "undefined":
|
|
711
711
|
if (value !== undefined) {
|
|
712
712
|
this.error(`Expected ${def.type.designType}, got ${typeOfValue}`);
|
|
@@ -723,7 +723,7 @@ else {
|
|
|
723
723
|
}
|
|
724
724
|
}
|
|
725
725
|
validateString(def, value) {
|
|
726
|
-
const filled = def.metadata.get("
|
|
726
|
+
const filled = def.metadata.get("meta.required");
|
|
727
727
|
if (filled) {
|
|
728
728
|
if (value.trim().length === 0) {
|
|
729
729
|
const message = typeof filled === "object" && filled.message ? filled.message : `Must not be empty`;
|
|
@@ -792,6 +792,17 @@ else {
|
|
|
792
792
|
}
|
|
793
793
|
return true;
|
|
794
794
|
}
|
|
795
|
+
validateBoolean(def, value) {
|
|
796
|
+
const filled = def.metadata.get("meta.required");
|
|
797
|
+
if (filled) {
|
|
798
|
+
if (value !== true) {
|
|
799
|
+
const message = typeof filled === "object" && filled.message ? filled.message : `Must be checked`;
|
|
800
|
+
this.error(message);
|
|
801
|
+
return false;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
return true;
|
|
805
|
+
}
|
|
795
806
|
constructor(def, opts) {
|
|
796
807
|
_define_property$1(this, "def", void 0);
|
|
797
808
|
_define_property$1(this, "opts", void 0);
|
|
@@ -998,7 +1009,7 @@ function buildJsonSchema(type) {
|
|
|
998
1009
|
if (schema.type === "number" && meta.get("expect.int")) schema.type = "integer";
|
|
999
1010
|
}
|
|
1000
1011
|
if (schema.type === "string") {
|
|
1001
|
-
if (meta.get("
|
|
1012
|
+
if (meta.get("meta.required")) schema.minLength = 1;
|
|
1002
1013
|
const minLength = meta.get("expect.minLength");
|
|
1003
1014
|
if (minLength) schema.minLength = typeof minLength === "number" ? minLength : minLength.length;
|
|
1004
1015
|
const maxLength = meta.get("expect.maxLength");
|
package/dist/utils.cjs
CHANGED
|
@@ -285,7 +285,7 @@ else {
|
|
|
285
285
|
this.error(`Expected ${def.type.designType}, got ${typeOfValue}`);
|
|
286
286
|
return false;
|
|
287
287
|
}
|
|
288
|
-
return
|
|
288
|
+
return this.validateBoolean(def, value);
|
|
289
289
|
case "undefined":
|
|
290
290
|
if (value !== undefined) {
|
|
291
291
|
this.error(`Expected ${def.type.designType}, got ${typeOfValue}`);
|
|
@@ -302,7 +302,7 @@ else {
|
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
304
|
validateString(def, value) {
|
|
305
|
-
const filled = def.metadata.get("
|
|
305
|
+
const filled = def.metadata.get("meta.required");
|
|
306
306
|
if (filled) {
|
|
307
307
|
if (value.trim().length === 0) {
|
|
308
308
|
const message = typeof filled === "object" && filled.message ? filled.message : `Must not be empty`;
|
|
@@ -371,6 +371,17 @@ else {
|
|
|
371
371
|
}
|
|
372
372
|
return true;
|
|
373
373
|
}
|
|
374
|
+
validateBoolean(def, value) {
|
|
375
|
+
const filled = def.metadata.get("meta.required");
|
|
376
|
+
if (filled) {
|
|
377
|
+
if (value !== true) {
|
|
378
|
+
const message = typeof filled === "object" && filled.message ? filled.message : `Must be checked`;
|
|
379
|
+
this.error(message);
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
return true;
|
|
384
|
+
}
|
|
374
385
|
constructor(def, opts) {
|
|
375
386
|
_define_property(this, "def", void 0);
|
|
376
387
|
_define_property(this, "opts", void 0);
|
|
@@ -590,7 +601,7 @@ function buildJsonSchema(type) {
|
|
|
590
601
|
if (schema.type === "number" && meta.get("expect.int")) schema.type = "integer";
|
|
591
602
|
}
|
|
592
603
|
if (schema.type === "string") {
|
|
593
|
-
if (meta.get("
|
|
604
|
+
if (meta.get("meta.required")) schema.minLength = 1;
|
|
594
605
|
const minLength = meta.get("expect.minLength");
|
|
595
606
|
if (minLength) schema.minLength = typeof minLength === "number" ? minLength : minLength.length;
|
|
596
607
|
const maxLength = meta.get("expect.maxLength");
|
package/dist/utils.d.ts
CHANGED
|
@@ -90,6 +90,7 @@ declare class Validator<T extends TAtscriptAnnotatedType = TAtscriptAnnotatedTyp
|
|
|
90
90
|
protected validatePrimitive(def: TAtscriptAnnotatedType<TAtscriptTypeFinal>, value: any): boolean;
|
|
91
91
|
protected validateString(def: TAtscriptAnnotatedType<TAtscriptTypeFinal>, value: string): boolean;
|
|
92
92
|
protected validateNumber(def: TAtscriptAnnotatedType<TAtscriptTypeFinal>, value: number): boolean;
|
|
93
|
+
protected validateBoolean(def: TAtscriptAnnotatedType<TAtscriptTypeFinal>, value: boolean): boolean;
|
|
93
94
|
}
|
|
94
95
|
/** Error thrown by {@link Validator.validate} when validation fails. Contains structured error details. */
|
|
95
96
|
declare class ValidatorError extends Error {
|
package/dist/utils.mjs
CHANGED
|
@@ -284,7 +284,7 @@ else {
|
|
|
284
284
|
this.error(`Expected ${def.type.designType}, got ${typeOfValue}`);
|
|
285
285
|
return false;
|
|
286
286
|
}
|
|
287
|
-
return
|
|
287
|
+
return this.validateBoolean(def, value);
|
|
288
288
|
case "undefined":
|
|
289
289
|
if (value !== undefined) {
|
|
290
290
|
this.error(`Expected ${def.type.designType}, got ${typeOfValue}`);
|
|
@@ -301,7 +301,7 @@ else {
|
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
303
|
validateString(def, value) {
|
|
304
|
-
const filled = def.metadata.get("
|
|
304
|
+
const filled = def.metadata.get("meta.required");
|
|
305
305
|
if (filled) {
|
|
306
306
|
if (value.trim().length === 0) {
|
|
307
307
|
const message = typeof filled === "object" && filled.message ? filled.message : `Must not be empty`;
|
|
@@ -370,6 +370,17 @@ else {
|
|
|
370
370
|
}
|
|
371
371
|
return true;
|
|
372
372
|
}
|
|
373
|
+
validateBoolean(def, value) {
|
|
374
|
+
const filled = def.metadata.get("meta.required");
|
|
375
|
+
if (filled) {
|
|
376
|
+
if (value !== true) {
|
|
377
|
+
const message = typeof filled === "object" && filled.message ? filled.message : `Must be checked`;
|
|
378
|
+
this.error(message);
|
|
379
|
+
return false;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
return true;
|
|
383
|
+
}
|
|
373
384
|
constructor(def, opts) {
|
|
374
385
|
_define_property(this, "def", void 0);
|
|
375
386
|
_define_property(this, "opts", void 0);
|
|
@@ -589,7 +600,7 @@ function buildJsonSchema(type) {
|
|
|
589
600
|
if (schema.type === "number" && meta.get("expect.int")) schema.type = "integer";
|
|
590
601
|
}
|
|
591
602
|
if (schema.type === "string") {
|
|
592
|
-
if (meta.get("
|
|
603
|
+
if (meta.get("meta.required")) schema.minLength = 1;
|
|
593
604
|
const minLength = meta.get("expect.minLength");
|
|
594
605
|
if (minLength) schema.minLength = typeof minLength === "number" ? minLength : minLength.length;
|
|
595
606
|
const maxLength = meta.get("expect.maxLength");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/typescript",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"description": "Atscript: typescript-gen support.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"homepage": "https://github.com/moostjs/atscript/tree/main/packages/typescript#readme",
|
|
71
71
|
"license": "ISC",
|
|
72
72
|
"peerDependencies": {
|
|
73
|
-
"@atscript/core": "^0.1.
|
|
73
|
+
"@atscript/core": "^0.1.15"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"@moostjs/event-cli": "^0.5.32",
|