@tsed/common
Version:
A TypeScript Framework on top of Express
40 lines • 962 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Allow = void 0;
const schema_1 = require("@tsed/schema");
/**
* 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.
*/
function Allow(...allowedRequiredValues) {
return schema_1.Allow(...allowedRequiredValues);
}
exports.Allow = Allow;
//# sourceMappingURL=allow.js.map