Function: asArray()
asArray<
T
,S
>(itemTransformer
,separator
,options
?):TTransformer
<Static
<TDecodeType
<S
>,unknown
[] & []>[],TArray
<S
>>
Create an array transformer. Split string with separator and apply itemTransformer to each item.
Type Parameters
Type Parameter |
---|
T |
S extends TSchema |
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
itemTransformer | TTransformer <T , S > | undefined | Transformer for each item |
separator | string | ',' | A string that separate each item |
options ? | ArrayOptions | undefined | Validation options (see ArrayOptions) |
Returns
TTransformer
<Static
<TDecodeType
<S
>, unknown
[] & []>[], TArray
<S
>>
Example
ts
// Example: "food, transport, rent" -> ['food', 'transport', 'rent']
Column('categories', asArray(asString()));