# Decorator MultipleOf
Decorator validation swagger schema inputModule | import { MultipleOf } from "@tsed/schema" |
---|---|
Source | /packages/schema/src/decorators/common/multipleOf.ts |
# Overview
function MultipleOf(multipleOf: number): (...args: any[]) => any;
Param | Type | Description |
---|---|---|
multipleOf | number | The multiple value allowed |
# 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/common.
# Example
# With primitive type
class Model {
@MultipleOf(2)
property: Number;
}
1
2
3
4
2
3
4
{
"type": "object",
"properties": {
"property": {
"type": "number",
"multipleOf": 2
}
}
}
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
# With array type
class Model {
@CollectionOf(number)
@MultipleOf(2)
property: number[];
}
1
2
3
4
5
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
2
3
4
5
6
7
8
9
10
11
12
Other topics
- Session & cookies
- Passport.js
- TypeORM
- Mongoose
- GraphQL
- Socket.io
- Swagger
- AJV
- Multer
- Serve static files
- Templating
- Throw HTTP Exceptions
- Customize 404
- AWS
- Seq
- OIDC
- Stripe
- Controllers
- Providers
- Model
- JsonMapper
- Middlewares
- Pipes
- Interceptors
- Authentication
- Hooks
- Exceptions
- Hooks
- Response Filter
- Injection scopes
- Custom providers
- Custom endpoint decorator
- Testing