MultipleOf
@tsed/schema
Usage
typescript
import { MultipleOf } from "@tsed/schema";
See /packages/specs/schema/src/types/decorators/common/multipleOf.ts.
Overview
ts
const MultipleOf: import("../../utils/withErrorMsg.js").ErrorChainedDecorator<(multipleOf: number) => (...args: any[]) => any>;
Description
A numeric instance is valid only if division by this keyword's value results in an integer.
WARNING
The value of multipleOf
MUST be a number, strictly greater than 0.
WARNING
For v6 user, use MultipleOf from @tsed/schema instead of @tsed/platform-http.
Example
With primitive type
typescript
class Model {
@MultipleOf(2)
property: Number;
}
json
{
"type": "object",
"properties": {
"property": {
"type": "number",
"multipleOf": 2
}
}
}
With array type
typescript
class Model {
@CollectionOf(number)
@MultipleOf(2)
property: number[];
}
Will produce:
json
{
"type": "object",
"properties": {
"property": {
"type": "array",
"items": {
"type": "number",
"multipleOf": 2
}
}
}
}