1 | "use strict";
|
2 | var __assign = (this && this.__assign) || function () {
|
3 | __assign = Object.assign || function(t) {
|
4 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5 | s = arguments[i];
|
6 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7 | t[p] = s[p];
|
8 | }
|
9 | return t;
|
10 | };
|
11 | return __assign.apply(this, arguments);
|
12 | };
|
13 | Object.defineProperty(exports, "__esModule", { value: true });
|
14 | exports.StringField = void 0;
|
15 | var class_validator_1 = require("class-validator");
|
16 | var utils_1 = require("../utils");
|
17 | var getCombinedDecorator_1 = require("./getCombinedDecorator");
|
18 | function StringField(options) {
|
19 | if (options === void 0) { options = {}; }
|
20 | var maxLenOption = options.maxLength ? { length: options.maxLength } : {};
|
21 | var uniqueOption = options.unique ? { unique: true } : {};
|
22 | var factories = getCombinedDecorator_1.getCombinedDecorator({
|
23 | fieldType: 'string',
|
24 | warthogColumnMeta: options,
|
25 | gqlFieldType: String,
|
26 | dbType: options.dataType || 'varchar',
|
27 | dbColumnOptions: __assign(__assign({}, maxLenOption), uniqueOption)
|
28 | });
|
29 | if (options.minLength) {
|
30 | factories.push(class_validator_1.MinLength(options.minLength));
|
31 | }
|
32 | if (options.maxLength) {
|
33 | factories.push(class_validator_1.MaxLength(options.maxLength));
|
34 | }
|
35 | return utils_1.composeMethodDecorators.apply(void 0, factories);
|
36 | }
|
37 | exports.StringField = StringField;
|
38 |
|
\ | No newline at end of file |