feat: add split feature to array
This commit is contained in:
parent
476a17be17
commit
fdfaac9aa0
@ -15,6 +15,14 @@ export default class SchemaArray<Type extends SchemaItem> extends SchemaItem<Arr
|
|||||||
return this
|
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>>> {
|
public parse(input: unknown, options?: { fast?: boolean }): ValidationResult<Array<SchemaInfer<Type>>> {
|
||||||
|
|
||||||
// check errors from itself
|
// check errors from itself
|
||||||
|
Loading…
x
Reference in New Issue
Block a user