UNPKG

@tsed/common

Version:
86 lines 1.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MaxLength = void 0; const schema_1 = require("@tsed/schema"); /** * A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword. * * The length of a string instance is defined as the number of its characters as defined by [RFC 7159](http://json-schema.org/latest/json-schema-validation.html#RFC7159). * * ::: warning * The value of maxLength MUST be a non-negative integer. * ::: * * ::: tip * Omitting this keyword has the same behavior as a value of 0. * ::: * * ::: warning * This decorator will be removed in v7. * For v6 user, use @@MaxLength@@ from @tsed/schema instead of @tsed/common. * ::: * * ## Example * ### With primitive type * * ```typescript * class Model { * @MaxLength(10) * property: number; * } * ``` * * Will produce: * * ```json * { * "type": "object", * "properties": { * "property": { * "type": "string", * "maxLength": 10 * } * } * } * ``` * * ### With array type * * ```typescript * class Model { * @MaxLength(10) * @CollectionOf(String) * property: string[]; * } * ``` * * Will produce: * * ```json * { * "type": "object", * "properties": { * "property": { * "type": "array", * "items": { * "type": "string", * "maxLength": 10 * } * } * } * } * ``` * * @param {number} maxLength The maximum length allowed * @decorator * @validation * @swagger * @schema * @ignore * @deprecated Since v6. Use @MaxLength decorator from @tsed/schema instead of. */ function MaxLength(maxLength) { return schema_1.MaxLength(maxLength); } exports.MaxLength = MaxLength; //# sourceMappingURL=maxLength.js.map