# Constant MinItems

Constant validation swagger schema input collections ajv-errors
Module
import { MinItems } from "@tsed/schema"
Source/packages/specs/schema/src/types/decorators/collections/minItems.ts

# Overview

const MinItems: import("../../utils/withErrorMsg").ErrorChainedDecorator<(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": "array",
      "minItems": 10,
      "items": {
        "type": "string"
      }
    }
  }
}
1
2
3
4
5
6
7
8
9
10
11
12