Allow
@tsed/schema
Usage
typescript
import { Allow } from "@tsed/schema";
See /packages/specs/schema/src/types/decorators/common/allow.ts.
Overview
ts
function Allow(...values: any[]): any;
Description
Add allowed values when the property or parameters is required.
Example on parameter:
typescript
@Post("/")
async method(@Allow("") @BodyParams("field") field: string) {}
Required will throw a BadRequest when the given value is
null
orundefined
but not for an empty string.
Example on model:
typescript
class Model {
@Allow("")
field: string;
}