# Decorator MaxProperties
Decorator validation swagger schema input collectionsModule | import { MaxProperties } from "@tsed/schema" |
---|---|
Source | /packages/schema/src/decorators/collections/maxProperties.ts |
# Overview
function MaxProperties(maxProperties: number): (...args: any[]) => any;
Param | Type | Description |
---|---|---|
maxProperties | number | The maximum properties allowed on the given object |
# Description
An object instance is valid against maxProperties
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
This decorator will be removed in v7. For v6 user, use MaxProperties from @tsed/schema instead of @tsed/common.
# Example
# On prop
class Model {
@MaxProperties(10)
property: any;
}
1
2
3
4
2
3
4
Will produce:
{
"type": "object",
"properties": {
"property": {
"type": "any",
"maxProperties": 10
}
}
}
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
# On class
@MaxProperties(10)
class Model {
}
1
2
3
2
3
Will produce:
{
"type": "object",
"maxProperties": 10
}
1
2
3
4
2
3
4
# On Parameter
class Model {
method(@Any() @MaxProperties(10) obj: any){}
}
1
2
3
4
2
3
4
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