MinItems
@tsed/schema
Usage
typescript
import { MinItems } from "@tsed/schema";
See /packages/specs/schema/src/types/decorators/collections/minItems.ts.
Overview
ts
const MinItems: import("../../utils/withErrorMsg.js").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/platform-http.
Example
typescript
class Model {
@CollectionOf(String)
@MinItems(10)
property: string[];
}
Will produce:
json
{
"type": "object",
"properties": {
"property": {
"type": "array",
"minItems": 10,
"items": {
"type": "string"
}
}
}
}