# Constant MaxItems

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

# Overview

const MaxItems: import("../../utils/withErrorMsg").ErrorChainedDecorator<(maxItems: number) => (...args: any[]) => any>;

# Description

The value maxItems MUST be a non-negative integer.

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

:: warning The value maxItems MUST be a non-negative integer. :::

:: warning This decorator will be removed in v7. For v6 user, use MaxItems from @tsed/schema instead of @tsed/common. :::

# Example

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

Will produce:

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