# Decorator Default
Decorator validation swagger schema inputModule | import { Default } from "@tsed/schema" |
---|---|
Source | /packages/schema/src/decorators/common/default.ts |
# Overview
function Default(defaultValue: string | number | boolean | {}): (...args: any[]) => any;
# Description
There are no restrictions placed on the value of this keyword.
WARNING
For v6 user, use Default from @tsed/schema instead of @tsed/common.
This keyword can be used to supply a default JSON value associated with a particular schema. It is RECOMMENDED that a default value be valid against the associated schema.
# Example
class Model {
@Default("10")
property: string = "10";
}
1
2
3
4
2
3
4
Will produce:
{
"type": "object",
"properties": {
"property": {
"type": "string",
"default": "10"
}
}
}
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
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