@tsed/common
Version:
A TypeScript Framework on top of Express
33 lines (32 loc) • 734 B
TypeScript
/**
* Add allowed values when the property or parameters is required.
*
* #### Example on parameter:
*
* ```typescript
* @Post("/")
* async method(@Required() @Allow("") @BodyParams("field") field: string) {}
* ```
* > Required will throw a BadRequest when the given value is `null` or `undefined` but not for an empty string.
*
* #### Example on model:
*
* ```typescript
* class Model {
* @Property()
* @Required()
* @Allow("")
* field: string;
* }
* ```
*
* @returns {Function}
* @decorator
* @operation
* @input
* @schema
* @validation
* @ignore
* @deprecated Since v6. Use @Allow decorator from @tsed/schema instead of.
*/
export declare function Allow(...allowedRequiredValues: any[]): any;