@dzeio/schema 0.2.0 → 0.3.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.
- package/dist/Schema.d.mts +6 -1
- package/dist/Schema.d.ts +6 -1
- package/dist/Schema.js +8 -0
- package/dist/Schema.mjs +8 -0
- package/package.json +1 -1
package/dist/Schema.d.mts
CHANGED
|
@@ -132,7 +132,7 @@ declare class SchemaAny extends SchemaItem {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
declare class SchemaDate extends SchemaItem<Date> {
|
|
135
|
-
parseString(format?: 'iso8601' | 'yy-mm-dd' | 'jj/mm/yy'):
|
|
135
|
+
parseString(format?: 'iso8601' | 'yy-mm-dd' | 'jj/mm/yy'): this;
|
|
136
136
|
isOfType(input: unknown): input is Date;
|
|
137
137
|
}
|
|
138
138
|
|
|
@@ -153,6 +153,11 @@ declare class SchemaArray<Type extends SchemaItem> extends SchemaItem<Array<Sche
|
|
|
153
153
|
* transform the array so it only contains one of each elements
|
|
154
154
|
*/
|
|
155
155
|
unique(): this;
|
|
156
|
+
/**
|
|
157
|
+
* split a string into an array
|
|
158
|
+
* @param [separator] default:`,` the separator to use
|
|
159
|
+
*/
|
|
160
|
+
split(separator?: string): void;
|
|
156
161
|
parse(input: unknown, options?: {
|
|
157
162
|
fast?: boolean;
|
|
158
163
|
}): ValidationResult<Array<SchemaInfer<Type>>>;
|
package/dist/Schema.d.ts
CHANGED
|
@@ -132,7 +132,7 @@ declare class SchemaAny extends SchemaItem {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
declare class SchemaDate extends SchemaItem<Date> {
|
|
135
|
-
parseString(format?: 'iso8601' | 'yy-mm-dd' | 'jj/mm/yy'):
|
|
135
|
+
parseString(format?: 'iso8601' | 'yy-mm-dd' | 'jj/mm/yy'): this;
|
|
136
136
|
isOfType(input: unknown): input is Date;
|
|
137
137
|
}
|
|
138
138
|
|
|
@@ -153,6 +153,11 @@ declare class SchemaArray<Type extends SchemaItem> extends SchemaItem<Array<Sche
|
|
|
153
153
|
* transform the array so it only contains one of each elements
|
|
154
154
|
*/
|
|
155
155
|
unique(): this;
|
|
156
|
+
/**
|
|
157
|
+
* split a string into an array
|
|
158
|
+
* @param [separator] default:`,` the separator to use
|
|
159
|
+
*/
|
|
160
|
+
split(separator?: string): void;
|
|
156
161
|
parse(input: unknown, options?: {
|
|
157
162
|
fast?: boolean;
|
|
158
163
|
}): ValidationResult<Array<SchemaInfer<Type>>>;
|
package/dist/Schema.js
CHANGED
|
@@ -224,6 +224,13 @@ var SchemaArray = class extends SchemaItem {
|
|
|
224
224
|
this.postProcess.push((input) => input.filter((it, idx) => input.indexOf(it) === idx));
|
|
225
225
|
return this;
|
|
226
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* split a string into an array
|
|
229
|
+
* @param [separator] default:`,` the separator to use
|
|
230
|
+
*/
|
|
231
|
+
split(separator = ",") {
|
|
232
|
+
this.addPreProcess((it) => typeof it === "string" ? it.split(separator) : it);
|
|
233
|
+
}
|
|
227
234
|
parse(input, options) {
|
|
228
235
|
const { valid, object, errors = [] } = super.parse(input, options);
|
|
229
236
|
if (!valid) {
|
|
@@ -449,6 +456,7 @@ var SchemaDate = class extends SchemaItem {
|
|
|
449
456
|
});
|
|
450
457
|
}
|
|
451
458
|
}
|
|
459
|
+
return this;
|
|
452
460
|
}
|
|
453
461
|
isOfType(input) {
|
|
454
462
|
return input instanceof Date;
|
package/dist/Schema.mjs
CHANGED
|
@@ -181,6 +181,13 @@ var SchemaArray = class extends SchemaItem {
|
|
|
181
181
|
this.postProcess.push((input) => input.filter((it, idx) => input.indexOf(it) === idx));
|
|
182
182
|
return this;
|
|
183
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* split a string into an array
|
|
186
|
+
* @param [separator] default:`,` the separator to use
|
|
187
|
+
*/
|
|
188
|
+
split(separator = ",") {
|
|
189
|
+
this.addPreProcess((it) => typeof it === "string" ? it.split(separator) : it);
|
|
190
|
+
}
|
|
184
191
|
parse(input, options) {
|
|
185
192
|
const { valid, object, errors = [] } = super.parse(input, options);
|
|
186
193
|
if (!valid) {
|
|
@@ -406,6 +413,7 @@ var SchemaDate = class extends SchemaItem {
|
|
|
406
413
|
});
|
|
407
414
|
}
|
|
408
415
|
}
|
|
416
|
+
return this;
|
|
409
417
|
}
|
|
410
418
|
isOfType(input) {
|
|
411
419
|
return input instanceof Date;
|