@dzeio/schema 0.3.0 → 0.3.2
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 +1 -1
- package/dist/Schema.d.ts +1 -1
- package/dist/Schema.js +7 -6
- package/dist/Schema.mjs +7 -6
- package/package.json +1 -1
package/dist/Schema.d.mts
CHANGED
|
@@ -157,7 +157,7 @@ declare class SchemaArray<Type extends SchemaItem> extends SchemaItem<Array<Sche
|
|
|
157
157
|
* split a string into an array
|
|
158
158
|
* @param [separator] default:`,` the separator to use
|
|
159
159
|
*/
|
|
160
|
-
split(separator?: string):
|
|
160
|
+
split(separator?: string): this;
|
|
161
161
|
parse(input: unknown, options?: {
|
|
162
162
|
fast?: boolean;
|
|
163
163
|
}): ValidationResult<Array<SchemaInfer<Type>>>;
|
package/dist/Schema.d.ts
CHANGED
|
@@ -157,7 +157,7 @@ declare class SchemaArray<Type extends SchemaItem> extends SchemaItem<Array<Sche
|
|
|
157
157
|
* split a string into an array
|
|
158
158
|
* @param [separator] default:`,` the separator to use
|
|
159
159
|
*/
|
|
160
|
-
split(separator?: string):
|
|
160
|
+
split(separator?: string): this;
|
|
161
161
|
parse(input: unknown, options?: {
|
|
162
162
|
fast?: boolean;
|
|
163
163
|
}): ValidationResult<Array<SchemaInfer<Type>>>;
|
package/dist/Schema.js
CHANGED
|
@@ -224,12 +224,9 @@ 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
227
|
split(separator = ",") {
|
|
232
228
|
this.addPreProcess((it) => typeof it === "string" ? it.split(separator) : it);
|
|
229
|
+
return this;
|
|
233
230
|
}
|
|
234
231
|
parse(input, options) {
|
|
235
232
|
const { valid, object, errors = [] } = super.parse(input, options);
|
|
@@ -284,6 +281,9 @@ var SchemaArray = class extends SchemaItem {
|
|
|
284
281
|
__decorateClass([
|
|
285
282
|
parceable()
|
|
286
283
|
], SchemaArray.prototype, "unique", 1);
|
|
284
|
+
__decorateClass([
|
|
285
|
+
parceable()
|
|
286
|
+
], SchemaArray.prototype, "split", 1);
|
|
287
287
|
|
|
288
288
|
// src/items/boolean.ts
|
|
289
289
|
var SchemaBoolean = class extends SchemaItem {
|
|
@@ -354,6 +354,7 @@ var SchemaObject = class extends SchemaItem {
|
|
|
354
354
|
};
|
|
355
355
|
}
|
|
356
356
|
const clone = (0, import_object_util2.objectClone)(object);
|
|
357
|
+
const res = {};
|
|
357
358
|
(0, import_object_util2.objectLoop)(this.model, (childSchema, key) => {
|
|
358
359
|
const childValue = clone[key];
|
|
359
360
|
const child = childSchema.parse(childValue);
|
|
@@ -363,13 +364,13 @@ var SchemaObject = class extends SchemaItem {
|
|
|
363
364
|
field: it.field ? `${key}.${it.field}` : key
|
|
364
365
|
})));
|
|
365
366
|
}
|
|
366
|
-
|
|
367
|
+
res[key] = child.object;
|
|
367
368
|
return child.valid || !(options == null ? void 0 : options.fast);
|
|
368
369
|
});
|
|
369
370
|
return {
|
|
370
371
|
valid: errors.length === 0,
|
|
371
372
|
errors,
|
|
372
|
-
object:
|
|
373
|
+
object: res
|
|
373
374
|
};
|
|
374
375
|
}
|
|
375
376
|
isOfType(input) {
|
package/dist/Schema.mjs
CHANGED
|
@@ -181,12 +181,9 @@ 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
184
|
split(separator = ",") {
|
|
189
185
|
this.addPreProcess((it) => typeof it === "string" ? it.split(separator) : it);
|
|
186
|
+
return this;
|
|
190
187
|
}
|
|
191
188
|
parse(input, options) {
|
|
192
189
|
const { valid, object, errors = [] } = super.parse(input, options);
|
|
@@ -241,6 +238,9 @@ var SchemaArray = class extends SchemaItem {
|
|
|
241
238
|
__decorateClass([
|
|
242
239
|
parceable()
|
|
243
240
|
], SchemaArray.prototype, "unique", 1);
|
|
241
|
+
__decorateClass([
|
|
242
|
+
parceable()
|
|
243
|
+
], SchemaArray.prototype, "split", 1);
|
|
244
244
|
|
|
245
245
|
// src/items/boolean.ts
|
|
246
246
|
var SchemaBoolean = class extends SchemaItem {
|
|
@@ -311,6 +311,7 @@ var SchemaObject = class extends SchemaItem {
|
|
|
311
311
|
};
|
|
312
312
|
}
|
|
313
313
|
const clone = objectClone(object);
|
|
314
|
+
const res = {};
|
|
314
315
|
objectLoop(this.model, (childSchema, key) => {
|
|
315
316
|
const childValue = clone[key];
|
|
316
317
|
const child = childSchema.parse(childValue);
|
|
@@ -320,13 +321,13 @@ var SchemaObject = class extends SchemaItem {
|
|
|
320
321
|
field: it.field ? `${key}.${it.field}` : key
|
|
321
322
|
})));
|
|
322
323
|
}
|
|
323
|
-
|
|
324
|
+
res[key] = child.object;
|
|
324
325
|
return child.valid || !(options == null ? void 0 : options.fast);
|
|
325
326
|
});
|
|
326
327
|
return {
|
|
327
328
|
valid: errors.length === 0,
|
|
328
329
|
errors,
|
|
329
|
-
object:
|
|
330
|
+
object: res
|
|
330
331
|
};
|
|
331
332
|
}
|
|
332
333
|
isOfType(input) {
|