MinProperties
@tsed/schema
Usage
typescript
import { MinProperties } from "@tsed/schema";
See /packages/specs/schema/src/types/decorators/collections/minProperties.ts.
Overview
ts
const MinProperties: import("../../utils/withErrorMsg.js").ErrorChainedDecorator<(minProperties: number) => (...args: any[]) => any>;
Description
An object instance is valid against minProperties
if its number of properties is less than, or equal to, the value of this keyword.
WARNING
The value of this keyword MUST be a non-negative integer.
WARNING
For v6 user, use MinProperties from @tsed/schema instead of @tsed/platform-http.
Example
On prop
typescript
class Model {
@MinProperties(10)
property: any;
}
Will produce:
json
{
"type": "object",
"properties": {
"property": {
"type": "any",
"minProperties": 10
}
}
}
On class
typescript
@MinProperties(10)
class Model {
}
Will produce:
json
{
"type": "object",
"minProperties": 10
}
On Parameter
typescript
class Model {
method(@Any() @MinProperties(10) obj: any){}
}