# MinItems Decorator validation swagger schema input collections

Module
import { MinItems } from "@tsed/schema"
Source/packages/schema/src/decorators/collections/minItems.ts

# Overview

function MinItems(minItems: number): (...args: any[]) => any;

# Description

An array instance is valid against minItems if its size is greater than, or equal to, the value of this keyword.

WARNING

The value minItems MUST be a non-negative integer.

TIP

Omitting this keyword has the same behavior as a value of 0.

WARNING

For v6 user, use MinItems from @tsed/schema instead of @tsed/common.

# Example

class Model {
   @CollectionOf(String)
   @MinItems(10)
   property: string[];
}
1
2
3
4
5

Will produce:

{
  "type": "object",
  "properties": {
    "property": {
      "type": "string",
      "minItems": 10
    }
  }
}
1
2
3
4
5
6
7
8
9

Other topics