# MultipleOf Decorator

Module
import { MultipleOf } from "@tsed/common"
Source/packages/common/src/jsonschema/decorators/multipleOf.ts

# Overview

function MultipleOf(multipleOf: number): (...parameters: any[]) => any;

# Description

A numeric instance is valid only if division by this keyword's value results in an integer.

!> The value of multipleOf MUST be a number, strictly greater than 0.

# Example

# With primitive type

class Model {
   @MultipleOf(2)
   property: Number;
}
1
2
3
4
{
  "type": "object",
  "properties": {
    "property": {
      "type": "number",
      "multipleOf": 2
    }
  }
}
1
2
3
4
5
6
7
8
9

# With array type

class Model {
   @PropertyType(number)
   @MultipleOf(2)
   property: number[];
}
1
2
3
4
5

Will produce:

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