Skip to content

CollectionOf

@tsed/schema

Usage

typescript
import { CollectionOf } from "@tsed/schema";

See /packages/specs/schema/src/types/decorators/collections/collectionOf.ts.

Overview

ts
function CollectionOf(type: any, collectionType?: any): CollectionOfChainedDecorators;

Description

Set the type of the item collection. The possible value is String, Boolean, Number, Date, Object, Class, etc...

typescript
class Model {
   @CollectionOf(String).MinLength(0).MaxLength(0)
   property: string[];
}

WARNING

You mustn't use the type Type = string | number as parameters Type.

This example doesn't work:

typescript
type Type = "string" | "number"
class Model {
   @CollectionOf(Type)
   property: Type[];
}

Released under the MIT License.