Compare commits

...

4 Commits

Author SHA1 Message Date
740c597f3c
0.3.0 2025-04-02 13:02:27 +02:00
fdfaac9aa0
feat: add split feature to array 2025-04-02 13:02:20 +02:00
476a17be17
0.2.1 2025-04-02 12:12:43 +02:00
50371dd1bd
fix: missing return this 2025-04-02 12:12:40 +02:00
4 changed files with 13 additions and 3 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@dzeio/schema",
"version": "0.2.0",
"version": "0.3.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@dzeio/schema",
"version": "0.2.0",
"version": "0.3.0",
"dependencies": {
"@dzeio/object-util": "^1.8.3",
"@standard-schema/spec": "^1.0.0",

View File

@ -1,6 +1,6 @@
{
"name": "@dzeio/schema",
"version": "0.2.0",
"version": "0.3.0",
"dependencies": {
"@dzeio/object-util": "^1.8.3"
},

View File

@ -15,6 +15,14 @@ export default class SchemaArray<Type extends SchemaItem> extends SchemaItem<Arr
return this
}
/**
* split a string into an array
* @param [separator] default:`,` the separator to use
*/
public split(separator = ',') {
this.addPreProcess((it) => typeof it === 'string' ? it.split(separator) : it)
}
public parse(input: unknown, options?: { fast?: boolean }): ValidationResult<Array<SchemaInfer<Type>>> {
// check errors from itself

View File

@ -25,6 +25,8 @@ export default class SchemaDate extends SchemaItem<Date> {
})
}
}
return this
}
public override isOfType(input: unknown): input is Date {