@tsed/common
Version:
A TypeScript Framework on top of Express
71 lines • 1.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Const = void 0;
const schema_1 = require("@tsed/schema");
/**
* The const keyword is used to restrict a value to a fixed value.
*
* ::: warning
* This decorator will be removed in v7.
* For v6 user, use @@Const@@ from @tsed/schema instead of @tsed/common.
* :::
*
* ## Example
* ### With a string
*
* ```typescript
* class Model {
* @Const("value1")
* property: "value1";
* }
* ```
*
* Will produce:
*
* ```json
* {
* "type": "object",
* "properties": {
* "property": {
* "type": "string",
* "const": "value1"
* }
* }
* }
* ```
* * ### With a boolean
*
* ```typescript
* class Model {
* @Const(true)
* property: boolean;
* }
* ```
*
* Will produce:
*
* ```json
* {
* "type": "object",
* "properties": {
* "property": {
* "type": "boolean",
* "const": true
* }
* }
* }
* ```
*
* @param {string | number | boolean } constValue
* @decorator
* @validation
* @swagger
* @schema
* @ignore
* @deprecated Since v6. Use @Const decorator from @tsed/schema instead of.
*/
function Const(constValue) {
return schema_1.Const(constValue);
}
exports.Const = Const;
//# sourceMappingURL=const.js.map