# MinProperties Decorator validation swagger schema input collections

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

# Overview

function MinProperties(minProperties: number): (...args: any[]) => any;
Param Type Description
minProperties number The minimum properties allowed on the object.

# 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/common.

# Example

# On prop

class Model {
   @MinProperties(10)
   property: any;
}
1
2
3
4

Will produce:

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

# On class

@MinProperties(10)
class Model {
}
1
2
3

Will produce:

{
  "type": "object",
  "minProperties": 10
}
1
2
3
4

# On Parameter


class Model {
  method(@Any() @MinProperties(10) obj: any){}
}
1
2
3
4

Other topics