# Allow Decorator operation input schema validation
Module | import { Allow } from "@tsed/common" |
---|---|
Source | /packages/common/src/mvc/decorators/allow.ts |
# Overview
function Allow(...allowedRequiredValues: any[]): any;
# Description
Add allowed values when the property or parameters is required.
# Example on parameter:
@Post("/")
async method(@Required() @Allow("") @BodyParams("field") field: string) {}
1
2
2
Required will throw a BadRequest when the given value is
null
orundefined
but not for an empty string.
# Example on model:
class Model {
@Property()
@Required()
@Allow("")
field: string;
}
1
2
3
4
5
6
2
3
4
5
6
- Session & cookies
- Passport.js
- TypeORM
- Mongoose
- GraphQL
- Socket.io
- Swagger
- AJV
- Multer
- Serve static files
- Templating
- Throw HTTP Exceptions
- Customize 404
- AWS
- Jest
- Seq
- Controllers
- Providers
- Model
- Converters
- Middlewares
- Pipes
- Interceptors
- Authentication
- Hooks
- Injection scopes
- Custom providers
- Custom endpoint decorator
- Testing