# Minimum Decorator validation swagger schema input

Module
import { Minimum } from "@tsed/schema"
Source/packages/schema/src/decorators/common/minimum.ts

# Overview

function Minimum(minimum: number, exclusive?: boolean): (...args: any[]) => any;
Param Type Description
minimum number The minimum value allowed

# Description

The value of minimum MUST be a number, representing an inclusive upper limit for a numeric instance.

If the instance is a number, then this keyword validates only if the instance is greater than or exactly equal to minimum.

WARNING

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

# Example

# With primitive type

class Model {
   @Minimum(10)
   property: number;
}
1
2
3
4

Will produce:

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

# With array type

class Model {
   @Minimum(10)
   @CollectionOf(Number)
   property: number[];
}
1
2
3
4
5

Will produce:

{
  "type": "object",
  "properties": {
    "property": {
      "type": "array",
      "items": {
         "type": "number",
         "minimum": 10
      }
    }
  }
}
1
2
3
4
5
6
7
8
9
10
11
12

Other topics