@dzeio/schema 0.0.4 → 0.0.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.
- package/dist/Schema.d.mts +11 -11
- package/dist/Schema.d.ts +11 -11
- package/dist/Schema.js +26 -31
- package/dist/Schema.mjs +26 -31
- package/package.json +1 -1
package/dist/Schema.d.mts
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
2
|
|
|
3
|
-
declare class SchemaNullable<Type extends SchemaItem> extends SchemaItem<SchemaInfer<Type> | undefined> {
|
|
4
|
-
readonly child: Type;
|
|
5
|
-
constructor(child: Type);
|
|
6
|
-
unwrap(): Type;
|
|
7
|
-
parse(input: unknown, options?: {
|
|
8
|
-
fast?: boolean;
|
|
9
|
-
}): ValidationResult<SchemaInfer<Type> | undefined>;
|
|
10
|
-
isOfType(input: unknown): input is SchemaInfer<Type> | undefined;
|
|
11
|
-
private isNull;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
3
|
declare abstract class SchemaItem<Type = any> implements StandardSchemaV1<Type> {
|
|
15
4
|
'~standard': StandardSchemaV1.Props<Type>;
|
|
16
5
|
/**
|
|
@@ -191,6 +180,17 @@ declare class SchemaLiteral<Type> extends SchemaItem<Type> {
|
|
|
191
180
|
isOfType(input: unknown): input is Type;
|
|
192
181
|
}
|
|
193
182
|
|
|
183
|
+
declare class SchemaNullable<Type extends SchemaItem> extends SchemaItem<SchemaInfer<Type> | undefined> {
|
|
184
|
+
readonly child: Type;
|
|
185
|
+
constructor(child: Type);
|
|
186
|
+
unwrap(): Type;
|
|
187
|
+
parse(input: unknown, options?: {
|
|
188
|
+
fast?: boolean;
|
|
189
|
+
}): ValidationResult<SchemaInfer<Type> | undefined>;
|
|
190
|
+
isOfType(input: unknown): input is SchemaInfer<Type> | undefined;
|
|
191
|
+
private isNull;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
194
|
declare class SchemaNumber extends SchemaItem<number> {
|
|
195
195
|
/**
|
|
196
196
|
* validate that the number is less or equal than {@link value}
|
package/dist/Schema.d.ts
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
2
|
|
|
3
|
-
declare class SchemaNullable<Type extends SchemaItem> extends SchemaItem<SchemaInfer<Type> | undefined> {
|
|
4
|
-
readonly child: Type;
|
|
5
|
-
constructor(child: Type);
|
|
6
|
-
unwrap(): Type;
|
|
7
|
-
parse(input: unknown, options?: {
|
|
8
|
-
fast?: boolean;
|
|
9
|
-
}): ValidationResult<SchemaInfer<Type> | undefined>;
|
|
10
|
-
isOfType(input: unknown): input is SchemaInfer<Type> | undefined;
|
|
11
|
-
private isNull;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
3
|
declare abstract class SchemaItem<Type = any> implements StandardSchemaV1<Type> {
|
|
15
4
|
'~standard': StandardSchemaV1.Props<Type>;
|
|
16
5
|
/**
|
|
@@ -191,6 +180,17 @@ declare class SchemaLiteral<Type> extends SchemaItem<Type> {
|
|
|
191
180
|
isOfType(input: unknown): input is Type;
|
|
192
181
|
}
|
|
193
182
|
|
|
183
|
+
declare class SchemaNullable<Type extends SchemaItem> extends SchemaItem<SchemaInfer<Type> | undefined> {
|
|
184
|
+
readonly child: Type;
|
|
185
|
+
constructor(child: Type);
|
|
186
|
+
unwrap(): Type;
|
|
187
|
+
parse(input: unknown, options?: {
|
|
188
|
+
fast?: boolean;
|
|
189
|
+
}): ValidationResult<SchemaInfer<Type> | undefined>;
|
|
190
|
+
isOfType(input: unknown): input is SchemaInfer<Type> | undefined;
|
|
191
|
+
private isNull;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
194
|
declare class SchemaNumber extends SchemaItem<number> {
|
|
195
195
|
/**
|
|
196
196
|
* validate that the number is less or equal than {@link value}
|
package/dist/Schema.js
CHANGED
|
@@ -57,34 +57,6 @@ var import_object_util3 = require("@dzeio/object-util");
|
|
|
57
57
|
|
|
58
58
|
// src/SchemaItem.ts
|
|
59
59
|
var import_object_util = require("@dzeio/object-util");
|
|
60
|
-
|
|
61
|
-
// src/items/nullable.ts
|
|
62
|
-
var SchemaNullable = class extends SchemaItem {
|
|
63
|
-
constructor(child) {
|
|
64
|
-
super([child]);
|
|
65
|
-
this.child = child;
|
|
66
|
-
}
|
|
67
|
-
unwrap() {
|
|
68
|
-
return this.child;
|
|
69
|
-
}
|
|
70
|
-
parse(input, options) {
|
|
71
|
-
if (this.isNull(input)) {
|
|
72
|
-
return {
|
|
73
|
-
valid: true,
|
|
74
|
-
object: void 0
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
return this.child.parse(input, options);
|
|
78
|
-
}
|
|
79
|
-
isOfType(input) {
|
|
80
|
-
return Array.isArray(input);
|
|
81
|
-
}
|
|
82
|
-
isNull(value) {
|
|
83
|
-
return typeof value === "undefined" || value === null;
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
// src/SchemaItem.ts
|
|
88
60
|
var _SchemaItem = class _SchemaItem {
|
|
89
61
|
constructor(items) {
|
|
90
62
|
// standard Schema V1 spec
|
|
@@ -324,6 +296,32 @@ __decorateClass([
|
|
|
324
296
|
parceable()
|
|
325
297
|
], SchemaBoolean.prototype, "parseString", 1);
|
|
326
298
|
|
|
299
|
+
// src/items/nullable.ts
|
|
300
|
+
var SchemaNullable = class extends SchemaItem {
|
|
301
|
+
constructor(child) {
|
|
302
|
+
super([child]);
|
|
303
|
+
this.child = child;
|
|
304
|
+
}
|
|
305
|
+
unwrap() {
|
|
306
|
+
return this.child;
|
|
307
|
+
}
|
|
308
|
+
parse(input, options) {
|
|
309
|
+
if (this.isNull(input)) {
|
|
310
|
+
return {
|
|
311
|
+
valid: true,
|
|
312
|
+
object: void 0
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
return this.child.parse(input, options);
|
|
316
|
+
}
|
|
317
|
+
isOfType(input) {
|
|
318
|
+
return Array.isArray(input);
|
|
319
|
+
}
|
|
320
|
+
isNull(value) {
|
|
321
|
+
return typeof value === "undefined" || value === null;
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
|
|
327
325
|
// src/items/object.ts
|
|
328
326
|
var import_object_util2 = require("@dzeio/object-util");
|
|
329
327
|
var SchemaObject = class extends SchemaItem {
|
|
@@ -679,9 +677,6 @@ var SchemaUnion = class extends SchemaItem {
|
|
|
679
677
|
// src/Schema.ts
|
|
680
678
|
function parceable() {
|
|
681
679
|
return (target, propertyKey, descriptor) => {
|
|
682
|
-
if (!(target instanceof SchemaItem)) {
|
|
683
|
-
throw new Error("the decorator is only usable on Schema");
|
|
684
|
-
}
|
|
685
680
|
if (!(propertyKey in target)) {
|
|
686
681
|
throw new Error("property not set in object");
|
|
687
682
|
}
|
package/dist/Schema.mjs
CHANGED
|
@@ -14,34 +14,6 @@ import { objectGet, objectLoop as objectLoop2, objectSet } from "@dzeio/object-u
|
|
|
14
14
|
|
|
15
15
|
// src/SchemaItem.ts
|
|
16
16
|
import { objectClean } from "@dzeio/object-util";
|
|
17
|
-
|
|
18
|
-
// src/items/nullable.ts
|
|
19
|
-
var SchemaNullable = class extends SchemaItem {
|
|
20
|
-
constructor(child) {
|
|
21
|
-
super([child]);
|
|
22
|
-
this.child = child;
|
|
23
|
-
}
|
|
24
|
-
unwrap() {
|
|
25
|
-
return this.child;
|
|
26
|
-
}
|
|
27
|
-
parse(input, options) {
|
|
28
|
-
if (this.isNull(input)) {
|
|
29
|
-
return {
|
|
30
|
-
valid: true,
|
|
31
|
-
object: void 0
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
return this.child.parse(input, options);
|
|
35
|
-
}
|
|
36
|
-
isOfType(input) {
|
|
37
|
-
return Array.isArray(input);
|
|
38
|
-
}
|
|
39
|
-
isNull(value) {
|
|
40
|
-
return typeof value === "undefined" || value === null;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// src/SchemaItem.ts
|
|
45
17
|
var _SchemaItem = class _SchemaItem {
|
|
46
18
|
constructor(items) {
|
|
47
19
|
// standard Schema V1 spec
|
|
@@ -281,6 +253,32 @@ __decorateClass([
|
|
|
281
253
|
parceable()
|
|
282
254
|
], SchemaBoolean.prototype, "parseString", 1);
|
|
283
255
|
|
|
256
|
+
// src/items/nullable.ts
|
|
257
|
+
var SchemaNullable = class extends SchemaItem {
|
|
258
|
+
constructor(child) {
|
|
259
|
+
super([child]);
|
|
260
|
+
this.child = child;
|
|
261
|
+
}
|
|
262
|
+
unwrap() {
|
|
263
|
+
return this.child;
|
|
264
|
+
}
|
|
265
|
+
parse(input, options) {
|
|
266
|
+
if (this.isNull(input)) {
|
|
267
|
+
return {
|
|
268
|
+
valid: true,
|
|
269
|
+
object: void 0
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
return this.child.parse(input, options);
|
|
273
|
+
}
|
|
274
|
+
isOfType(input) {
|
|
275
|
+
return Array.isArray(input);
|
|
276
|
+
}
|
|
277
|
+
isNull(value) {
|
|
278
|
+
return typeof value === "undefined" || value === null;
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
|
|
284
282
|
// src/items/object.ts
|
|
285
283
|
import { isObject, objectClone, objectLoop } from "@dzeio/object-util";
|
|
286
284
|
var SchemaObject = class extends SchemaItem {
|
|
@@ -636,9 +634,6 @@ var SchemaUnion = class extends SchemaItem {
|
|
|
636
634
|
// src/Schema.ts
|
|
637
635
|
function parceable() {
|
|
638
636
|
return (target, propertyKey, descriptor) => {
|
|
639
|
-
if (!(target instanceof SchemaItem)) {
|
|
640
|
-
throw new Error("the decorator is only usable on Schema");
|
|
641
|
-
}
|
|
642
637
|
if (!(propertyKey in target)) {
|
|
643
638
|
throw new Error("property not set in object");
|
|
644
639
|
}
|