@dzeio/schema 0.2.1 → 0.3.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/dist/Schema.d.mts +5 -0
- package/dist/Schema.d.ts +5 -0
- package/dist/Schema.js +7 -0
- package/dist/Schema.mjs +7 -0
- package/package.json +1 -1
package/dist/Schema.d.mts
CHANGED
|
@@ -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): this;
|
|
156
161
|
parse(input: unknown, options?: {
|
|
157
162
|
fast?: boolean;
|
|
158
163
|
}): ValidationResult<Array<SchemaInfer<Type>>>;
|
package/dist/Schema.d.ts
CHANGED
|
@@ -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): this;
|
|
156
161
|
parse(input: unknown, options?: {
|
|
157
162
|
fast?: boolean;
|
|
158
163
|
}): ValidationResult<Array<SchemaInfer<Type>>>;
|
package/dist/Schema.js
CHANGED
|
@@ -224,6 +224,10 @@ 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
|
+
split(separator = ",") {
|
|
228
|
+
this.addPreProcess((it) => typeof it === "string" ? it.split(separator) : it);
|
|
229
|
+
return this;
|
|
230
|
+
}
|
|
227
231
|
parse(input, options) {
|
|
228
232
|
const { valid, object, errors = [] } = super.parse(input, options);
|
|
229
233
|
if (!valid) {
|
|
@@ -277,6 +281,9 @@ var SchemaArray = class extends SchemaItem {
|
|
|
277
281
|
__decorateClass([
|
|
278
282
|
parceable()
|
|
279
283
|
], SchemaArray.prototype, "unique", 1);
|
|
284
|
+
__decorateClass([
|
|
285
|
+
parceable()
|
|
286
|
+
], SchemaArray.prototype, "split", 1);
|
|
280
287
|
|
|
281
288
|
// src/items/boolean.ts
|
|
282
289
|
var SchemaBoolean = class extends SchemaItem {
|
package/dist/Schema.mjs
CHANGED
|
@@ -181,6 +181,10 @@ 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
|
+
split(separator = ",") {
|
|
185
|
+
this.addPreProcess((it) => typeof it === "string" ? it.split(separator) : it);
|
|
186
|
+
return this;
|
|
187
|
+
}
|
|
184
188
|
parse(input, options) {
|
|
185
189
|
const { valid, object, errors = [] } = super.parse(input, options);
|
|
186
190
|
if (!valid) {
|
|
@@ -234,6 +238,9 @@ var SchemaArray = class extends SchemaItem {
|
|
|
234
238
|
__decorateClass([
|
|
235
239
|
parceable()
|
|
236
240
|
], SchemaArray.prototype, "unique", 1);
|
|
241
|
+
__decorateClass([
|
|
242
|
+
parceable()
|
|
243
|
+
], SchemaArray.prototype, "split", 1);
|
|
237
244
|
|
|
238
245
|
// src/items/boolean.ts
|
|
239
246
|
var SchemaBoolean = class extends SchemaItem {
|