@nest-omni/core 2.0.1-9 → 3.1.1-9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +4 -0
- package/package.json +150 -46
- package/.hygen/new/crud/controller.ejs.t +0 -82
- package/.hygen/new/crud/create.dto.ejs.t +0 -12
- package/.hygen/new/crud/entity.ejs.t +0 -26
- package/.hygen/new/crud/get.dto.ejs.t +0 -19
- package/.hygen/new/crud/index-dto.ejs.t +0 -29
- package/.hygen/new/crud/index-response.dto.ejs.t +0 -18
- package/.hygen/new/crud/module.ejs.t +0 -32
- package/.hygen/new/crud/prompt.js +0 -89
- package/.hygen/new/crud/service.ejs.t +0 -76
- package/.hygen/new/crud/update.dto.ejs.t +0 -11
- package/.hygen/new/module/controller.ejs.t +0 -93
- package/.hygen/new/module/create-command.ejs.t +0 -90
- package/.hygen/new/module/create.dto.ejs.t +0 -11
- package/.hygen/new/module/dto.ejs.t +0 -24
- package/.hygen/new/module/entity.ejs.t +0 -33
- package/.hygen/new/module/get-query.ejs.t +0 -57
- package/.hygen/new/module/module.ejs.t +0 -44
- package/.hygen/new/module/not-found.exception.ejs.t +0 -18
- package/.hygen/new/module/page-options.dto.ejs.t +0 -12
- package/.hygen/new/module/prompt.js +0 -104
- package/.hygen/new/module/repository.ejs.t +0 -16
- package/.hygen/new/module/service.ejs.t +0 -139
- package/.hygen/new/module/translation-dto.ejs.t +0 -27
- package/.hygen/new/module/translation-entity.ejs.t +0 -40
- package/.hygen/new/module/translation-repository.ejs.t +0 -16
- package/.hygen/new/module/update.dto.ejs.t +0 -10
- package/.hygen.js +0 -116
- package/common/abstract-client.service.d.ts +0 -16
- package/common/abstract-client.service.js +0 -35
- package/common/abstract.entity.d.ts +0 -18
- package/common/abstract.entity.js +0 -78
- package/common/boilerplate.polyfill.d.ts +0 -39
- package/common/boilerplate.polyfill.js +0 -77
- package/common/dto/abstract.dto.d.ts +0 -13
- package/common/dto/abstract.dto.js +0 -59
- package/common/dto/bulk-id.dto.d.ts +0 -3
- package/common/dto/bulk-id.dto.js +0 -27
- package/common/dto/create-translation.dto.d.ts +0 -5
- package/common/dto/create-translation.dto.js +0 -25
- package/common/dto/index.d.ts +0 -6
- package/common/dto/index.js +0 -22
- package/common/dto/page-meta.dto.d.ts +0 -15
- package/common/dto/page-meta.dto.js +0 -48
- package/common/dto/page-options.dto.d.ts +0 -8
- package/common/dto/page-options.dto.js +0 -52
- package/common/dto/page.dto.d.ts +0 -11
- package/common/dto/page.dto.js +0 -53
- package/common/index.d.ts +0 -7
- package/common/index.js +0 -23
- package/common/snake-naming.strategy.d.ts +0 -11
- package/common/snake-naming.strategy.js +0 -37
- package/common/types.d.ts +0 -9
- package/common/types.js +0 -2
- package/common/utils.d.ts +0 -3
- package/common/utils.js +0 -24
- package/constants/index.d.ts +0 -2
- package/constants/index.js +0 -18
- package/constants/language-code.d.ts +0 -5
- package/constants/language-code.js +0 -9
- package/constants/order.d.ts +0 -4
- package/constants/order.js +0 -8
- package/decorators/api-page-ok-response.decorator.d.ts +0 -5
- package/decorators/api-page-ok-response.decorator.js +0 -24
- package/decorators/auth-user.decorator.d.ts +0 -1
- package/decorators/auth-user.decorator.js +0 -14
- package/decorators/controller.decorator.d.ts +0 -1
- package/decorators/controller.decorator.js +0 -10
- package/decorators/field.decorators.d.ts +0 -79
- package/decorators/field.decorators.js +0 -497
- package/decorators/http.decorators.d.ts +0 -3
- package/decorators/http.decorators.js +0 -7
- package/decorators/index.d.ts +0 -12
- package/decorators/index.js +0 -28
- package/decorators/operation.decorator.d.ts +0 -1
- package/decorators/operation.decorator.js +0 -6
- package/decorators/property.decorators.d.ts +0 -15
- package/decorators/property.decorators.js +0 -31
- package/decorators/public-route.decorator.d.ts +0 -3
- package/decorators/public-route.decorator.js +0 -7
- package/decorators/swagger.schema.d.ts +0 -5
- package/decorators/swagger.schema.js +0 -78
- package/decorators/timestamp-column.decorator.d.ts +0 -1
- package/decorators/timestamp-column.decorator.js +0 -27
- package/decorators/transform.decorators.d.ts +0 -8
- package/decorators/transform.decorators.js +0 -100
- package/decorators/translate.decorator.d.ts +0 -5
- package/decorators/translate.decorator.js +0 -17
- package/decorators/use-dto.decorator.d.ts +0 -4
- package/decorators/use-dto.decorator.js +0 -8
- package/decorators/user-check.decorator.d.ts +0 -6
- package/decorators/user-check.decorator.js +0 -21
- package/decorators/user.decorator.d.ts +0 -12
- package/decorators/user.decorator.js +0 -44
- package/decorators/user_auth.decorator.d.ts +0 -1
- package/decorators/user_auth.decorator.js +0 -15
- package/decorators/validator.decorators.d.ts +0 -11
- package/decorators/validator.decorators.js +0 -78
- package/exceptions/file-not-image.exception.d.ts +0 -4
- package/exceptions/file-not-image.exception.js +0 -10
- package/exceptions/index.d.ts +0 -2
- package/exceptions/index.js +0 -18
- package/exceptions/page-type.exception.d.ts +0 -4
- package/exceptions/page-type.exception.js +0 -10
- package/exceptions/user-not-found.exception.d.ts +0 -4
- package/exceptions/user-not-found.exception.js +0 -10
- package/filters/bad-request.filter.d.ts +0 -5
- package/filters/bad-request.filter.js +0 -71
- package/filters/constraint-errors.d.ts +0 -1
- package/filters/constraint-errors.js +0 -6
- package/filters/index.d.ts +0 -3
- package/filters/index.js +0 -19
- package/filters/query-failed.filter.d.ts +0 -10
- package/filters/query-failed.filter.js +0 -42
- package/health-checker/health-checker.controller.d.ts +0 -15
- package/health-checker/health-checker.controller.js +0 -72
- package/health-checker/health-checker.module.d.ts +0 -2
- package/health-checker/health-checker.module.js +0 -25
- package/health-checker/health-indicators/service.indicator.d.ts +0 -8
- package/health-checker/health-indicators/service.indicator.js +0 -66
- package/helpers/common.helper.d.ts +0 -3
- package/helpers/common.helper.js +0 -36
- package/helpers/date.helper.d.ts +0 -10
- package/helpers/date.helper.js +0 -57
- package/helpers/index.d.ts +0 -2
- package/helpers/index.js +0 -18
- package/i18n/en_US/validation.json +0 -41
- package/i18n/zh_CN/validation.json +0 -41
- package/index.d.ts +0 -11
- package/interceptors/index.d.ts +0 -2
- package/interceptors/index.js +0 -18
- package/interceptors/language-interceptor.service.d.ts +0 -6
- package/interceptors/language-interceptor.service.js +0 -29
- package/interceptors/translation-interceptor.service.d.ts +0 -5
- package/interceptors/translation-interceptor.service.js +0 -34
- package/interfaces/IApiFile.d.ts +0 -4
- package/interfaces/IApiFile.js +0 -2
- package/interfaces/IFile.d.ts +0 -8
- package/interfaces/IFile.js +0 -2
- package/interfaces/ITranslationDecoratorInterface.d.ts +0 -3
- package/interfaces/ITranslationDecoratorInterface.js +0 -2
- package/interfaces/index.d.ts +0 -3
- package/interfaces/index.js +0 -19
- package/interfaces/response.d.ts +0 -25
- package/interfaces/response.js +0 -2
- package/middlewares/index.d.ts +0 -4
- package/middlewares/index.js +0 -20
- package/middlewares/omni-auth.middleware.d.ts +0 -1
- package/middlewares/omni-auth.middleware.js +0 -13
- package/middlewares/powerby.middleware.d.ts +0 -1
- package/middlewares/powerby.middleware.js +0 -10
- package/middlewares/request-id.middleware.d.ts +0 -7
- package/middlewares/request-id.middleware.js +0 -22
- package/middlewares/xml.middleware.d.ts +0 -4
- package/middlewares/xml.middleware.js +0 -24
- package/providers/context.provider.d.ts +0 -34
- package/providers/context.provider.js +0 -80
- package/providers/generator.provider.d.ts +0 -9
- package/providers/generator.provider.js +0 -50
- package/providers/index.d.ts +0 -2
- package/providers/index.js +0 -18
- package/setup/bootstrap.setup.d.ts +0 -2
- package/setup/bootstrap.setup.js +0 -227
- package/setup/index.d.ts +0 -1
- package/setup/index.js +0 -17
- package/shared/index.d.ts +0 -2
- package/shared/index.js +0 -18
- package/shared/serviceRegistryModule.d.ts +0 -2
- package/shared/serviceRegistryModule.js +0 -111
- package/shared/services/api-config.service.d.ts +0 -58
- package/shared/services/api-config.service.js +0 -302
- package/shared/services/generator.service.d.ts +0 -4
- package/shared/services/generator.service.js +0 -23
- package/shared/services/index.d.ts +0 -4
- package/shared/services/index.js +0 -20
- package/shared/services/translation.service.d.ts +0 -9
- package/shared/services/translation.service.js +0 -70
- package/shared/services/validator.service.d.ts +0 -3
- package/shared/services/validator.service.js +0 -20
- package/tsconfig.tsbuildinfo +0 -1
- package/validator-json/decorators.d.ts +0 -6
- package/validator-json/decorators.js +0 -22
- package/validator-json/default.d.ts +0 -6
- package/validator-json/default.js +0 -130
- package/validator-json/defaultConverters.d.ts +0 -8
- package/validator-json/defaultConverters.js +0 -376
- package/validator-json/index.d.ts +0 -4
- package/validator-json/index.js +0 -20
- package/validator-json/options.d.ts +0 -11
- package/validator-json/options.js +0 -10
- package/validators/file-mimetype.validator.d.ts +0 -13
- package/validators/file-mimetype.validator.js +0 -21
- package/validators/index.d.ts +0 -6
- package/validators/index.js +0 -22
- package/validators/is-exists.validator.d.ts +0 -18
- package/validators/is-exists.validator.js +0 -62
- package/validators/is-unique.validator.d.ts +0 -17
- package/validators/is-unique.validator.js +0 -93
- package/validators/phone-country-code.validator.d.ts +0 -2
- package/validators/phone-country-code.validator.js +0 -29
- package/validators/same-as.validator.d.ts +0 -2
- package/validators/same-as.validator.js +0 -24
- package/validators/skip-empty.validator.d.ts +0 -1
- package/validators/skip-empty.validator.js +0 -17
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { ValidationArguments, ValidationOptions, ValidatorConstraintInterface } from 'class-validator';
|
|
2
|
-
import type { EntitySchema, FindOptionsWhere, ObjectType } from 'typeorm';
|
|
3
|
-
import { DataSource } from 'typeorm';
|
|
4
|
-
export declare class IsExistsValidator implements ValidatorConstraintInterface {
|
|
5
|
-
private readonly dataSource;
|
|
6
|
-
constructor(dataSource: DataSource);
|
|
7
|
-
validate<E>(value: string, args: IExistsValidationArguments<E>): Promise<boolean>;
|
|
8
|
-
defaultMessage(args: ValidationArguments): string;
|
|
9
|
-
}
|
|
10
|
-
type ExistsValidationConstraints<E> = [
|
|
11
|
-
ObjectType<E> | EntitySchema<E> | string,
|
|
12
|
-
(validationArguments: ValidationArguments) => FindOptionsWhere<E>
|
|
13
|
-
];
|
|
14
|
-
interface IExistsValidationArguments<E> extends ValidationArguments {
|
|
15
|
-
constraints: ExistsValidationConstraints<E>;
|
|
16
|
-
}
|
|
17
|
-
export declare function IsExists<E>(constraints: Partial<ExistsValidationConstraints<E>>, validationOptions?: ValidationOptions): PropertyDecorator;
|
|
18
|
-
export {};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.IsExistsValidator = void 0;
|
|
22
|
-
exports.IsExists = IsExists;
|
|
23
|
-
const class_validator_1 = require("class-validator");
|
|
24
|
-
const typeorm_1 = require("typeorm");
|
|
25
|
-
const typeorm_transactional_1 = require("typeorm-transactional");
|
|
26
|
-
const nestjs_i18n_1 = require("nestjs-i18n");
|
|
27
|
-
const common_1 = require("@nestjs/common");
|
|
28
|
-
let IsExistsValidator = class IsExistsValidator {
|
|
29
|
-
constructor(dataSource) {
|
|
30
|
-
this.dataSource = dataSource;
|
|
31
|
-
this.dataSource = (0, typeorm_transactional_1.getDataSourceByName)('default');
|
|
32
|
-
}
|
|
33
|
-
validate(value, args) {
|
|
34
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
const [entityClass, findCondition] = args.constraints;
|
|
36
|
-
args.value = value;
|
|
37
|
-
return ((yield this.dataSource.getRepository(entityClass).count({
|
|
38
|
-
where: findCondition(args),
|
|
39
|
-
})) > 0);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
defaultMessage(args) {
|
|
43
|
-
return (0, nestjs_i18n_1.i18nValidationMessage)('validation.IS_EXISTS')(args);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
exports.IsExistsValidator = IsExistsValidator;
|
|
47
|
-
exports.IsExistsValidator = IsExistsValidator = __decorate([
|
|
48
|
-
(0, common_1.Injectable)(),
|
|
49
|
-
(0, class_validator_1.ValidatorConstraint)({ name: 'isExists', async: true }),
|
|
50
|
-
__metadata("design:paramtypes", [typeorm_1.DataSource])
|
|
51
|
-
], IsExistsValidator);
|
|
52
|
-
function IsExists(constraints, validationOptions) {
|
|
53
|
-
return (object, propertyName) => {
|
|
54
|
-
(0, class_validator_1.registerDecorator)({
|
|
55
|
-
target: object.constructor,
|
|
56
|
-
propertyName,
|
|
57
|
-
options: validationOptions,
|
|
58
|
-
constraints,
|
|
59
|
-
validator: IsExistsValidator,
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ValidationArguments, ValidationOptions, ValidatorConstraintInterface } from 'class-validator';
|
|
2
|
-
import { DataSource, EntitySchema, FindOptionsWhere, ObjectType } from 'typeorm';
|
|
3
|
-
export declare class IsUniqueValidator implements ValidatorConstraintInterface {
|
|
4
|
-
private readonly dataSource;
|
|
5
|
-
constructor(dataSource: DataSource);
|
|
6
|
-
validate<E>(value: string, args: IUniqueValidationArguments<E>): Promise<boolean>;
|
|
7
|
-
defaultMessage(args: ValidationArguments): string;
|
|
8
|
-
}
|
|
9
|
-
type UniqueValidationConstraints<E> = [
|
|
10
|
-
ObjectType<E> | EntitySchema<E> | string,
|
|
11
|
-
(validationArguments: ValidationArguments) => FindOptionsWhere<E>
|
|
12
|
-
];
|
|
13
|
-
interface IUniqueValidationArguments<E> extends ValidationArguments {
|
|
14
|
-
constraints: UniqueValidationConstraints<E>;
|
|
15
|
-
}
|
|
16
|
-
export declare function IsUnique<E>(constraints: Partial<UniqueValidationConstraints<E>>, validationOptions?: ValidationOptions): PropertyDecorator;
|
|
17
|
-
export {};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.IsUniqueValidator = void 0;
|
|
22
|
-
exports.IsUnique = IsUnique;
|
|
23
|
-
const class_validator_1 = require("class-validator");
|
|
24
|
-
const typeorm_1 = require("typeorm");
|
|
25
|
-
const typeorm_transactional_1 = require("typeorm-transactional");
|
|
26
|
-
const nestjs_i18n_1 = require("nestjs-i18n");
|
|
27
|
-
let IsUniqueValidator = class IsUniqueValidator {
|
|
28
|
-
constructor(dataSource) {
|
|
29
|
-
this.dataSource = dataSource;
|
|
30
|
-
this.dataSource = (0, typeorm_transactional_1.getDataSourceByName)('default');
|
|
31
|
-
}
|
|
32
|
-
validate(value, args) {
|
|
33
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
const [entityClass, findCondition] = args.constraints;
|
|
35
|
-
args.value = value;
|
|
36
|
-
let exists;
|
|
37
|
-
const defCon = findCondition(args);
|
|
38
|
-
const pkCols = this.dataSource
|
|
39
|
-
.getMetadata(entityClass)
|
|
40
|
-
.primaryColumns.map((column) => column.propertyName);
|
|
41
|
-
const isNew = pkCols.some((pk) => args.object[pk]);
|
|
42
|
-
if (!isNew) {
|
|
43
|
-
exists =
|
|
44
|
-
(yield this.dataSource
|
|
45
|
-
.getRepository(entityClass)
|
|
46
|
-
.count({ where: defCon })) < 1;
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
const entities = yield this.dataSource
|
|
50
|
-
.getRepository(entityClass)
|
|
51
|
-
.createQueryBuilder()
|
|
52
|
-
.where(defCon)
|
|
53
|
-
.select(pkCols)
|
|
54
|
-
.limit(2)
|
|
55
|
-
.execute();
|
|
56
|
-
const entityCount = entities.length;
|
|
57
|
-
if (entityCount === 1) {
|
|
58
|
-
const entity = entities[0];
|
|
59
|
-
const oldPk = {};
|
|
60
|
-
const newPk = {};
|
|
61
|
-
pkCols.map((pk) => {
|
|
62
|
-
oldPk[pk] = entity[pk];
|
|
63
|
-
newPk[pk] = args.object[pk];
|
|
64
|
-
});
|
|
65
|
-
exists = JSON.stringify(oldPk) === JSON.stringify(newPk);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
exists = entityCount < 1;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return exists;
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
defaultMessage(args) {
|
|
75
|
-
return (0, nestjs_i18n_1.i18nValidationMessage)('validation.IS_UNIQUE')(args);
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
exports.IsUniqueValidator = IsUniqueValidator;
|
|
79
|
-
exports.IsUniqueValidator = IsUniqueValidator = __decorate([
|
|
80
|
-
(0, class_validator_1.ValidatorConstraint)({ name: 'isUnique', async: true }),
|
|
81
|
-
__metadata("design:paramtypes", [typeorm_1.DataSource])
|
|
82
|
-
], IsUniqueValidator);
|
|
83
|
-
function IsUnique(constraints, validationOptions) {
|
|
84
|
-
return function (object, propertyName) {
|
|
85
|
-
(0, class_validator_1.registerDecorator)({
|
|
86
|
-
target: object.constructor,
|
|
87
|
-
propertyName,
|
|
88
|
-
options: validationOptions,
|
|
89
|
-
constraints,
|
|
90
|
-
validator: IsUniqueValidator,
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IsPhoneNumberWithCountryCode = IsPhoneNumberWithCountryCode;
|
|
4
|
-
const class_validator_1 = require("class-validator");
|
|
5
|
-
function IsPhoneNumberWithCountryCode(validationOptions) {
|
|
6
|
-
return function (object, propertyName) {
|
|
7
|
-
(0, class_validator_1.ValidateIf)((_, value) => !!value)(object, propertyName);
|
|
8
|
-
const countryCodePropertyName = 'countryCode';
|
|
9
|
-
(0, class_validator_1.registerDecorator)({
|
|
10
|
-
name: 'isPhoneNumberWithCountryCode',
|
|
11
|
-
target: object.constructor,
|
|
12
|
-
propertyName: propertyName,
|
|
13
|
-
constraints: [countryCodePropertyName],
|
|
14
|
-
options: validationOptions,
|
|
15
|
-
validator: {
|
|
16
|
-
validate(value, args) {
|
|
17
|
-
const [countryCodePropertyName] = args.constraints;
|
|
18
|
-
const countryCode = args.object[countryCodePropertyName];
|
|
19
|
-
return (0, class_validator_1.isPhoneNumber)(value, countryCode);
|
|
20
|
-
},
|
|
21
|
-
defaultMessage(args) {
|
|
22
|
-
const [countryCodePropertyName] = args.constraints;
|
|
23
|
-
const countryCode = args.object[countryCodePropertyName];
|
|
24
|
-
return `$property must be a valid phone number in the country code ${countryCode}`;
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SameAs = SameAs;
|
|
4
|
-
const class_validator_1 = require("class-validator");
|
|
5
|
-
function SameAs(property, validationOptions) {
|
|
6
|
-
return function (object, propertyName) {
|
|
7
|
-
(0, class_validator_1.registerDecorator)({
|
|
8
|
-
name: 'sameAs',
|
|
9
|
-
target: object.constructor,
|
|
10
|
-
propertyName,
|
|
11
|
-
options: validationOptions,
|
|
12
|
-
constraints: [property],
|
|
13
|
-
validator: {
|
|
14
|
-
validate(value, args) {
|
|
15
|
-
const [relatedPropertyName] = args.constraints;
|
|
16
|
-
return (args === null || args === void 0 ? void 0 : args.object[relatedPropertyName]) === value;
|
|
17
|
-
},
|
|
18
|
-
defaultMessage() {
|
|
19
|
-
return '$property must match $constraint1';
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function SkipEmpty(field?: string): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SkipEmpty = SkipEmpty;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const swagger_1 = require("@nestjs/swagger");
|
|
6
|
-
const class_validator_1 = require("class-validator");
|
|
7
|
-
const lodash_1 = require("lodash");
|
|
8
|
-
function SkipEmpty(field) {
|
|
9
|
-
return (0, common_1.applyDecorators)((0, swagger_1.ApiProperty)({ required: false }), (0, class_validator_1.ValidateIf)((obj, value) => {
|
|
10
|
-
if (field) {
|
|
11
|
-
value = obj[field];
|
|
12
|
-
}
|
|
13
|
-
return !(value === null ||
|
|
14
|
-
value === undefined ||
|
|
15
|
-
((0, lodash_1.isString)(value) && value.trim() === ''));
|
|
16
|
-
}));
|
|
17
|
-
}
|