@hosterai/types 0.0.25 → 0.0.27
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/README.md +49 -8
- package/dist/dtos/addon-field.dto.d.ts +7 -0
- package/dist/dtos/addon-field.dto.js +11 -0
- package/dist/dtos/attachment.dto.js +17 -0
- package/dist/dtos/attribute-field.dto.d.ts +19 -0
- package/dist/dtos/attribute-field.dto.js +64 -0
- package/dist/dtos/base-response.dto.js +11 -0
- package/dist/dtos/client-data.dto.js +82 -0
- package/dist/dtos/company-data.dto.js +97 -0
- package/dist/dtos/country.dto.d.ts +7 -0
- package/dist/dtos/country.dto.js +21 -0
- package/dist/dtos/error-response.dto.js +15 -0
- package/dist/dtos/field.dto.d.ts +8 -13
- package/dist/dtos/field.dto.js +22 -47
- package/dist/dtos/info.dto.d.ts +0 -5
- package/dist/dtos/info.dto.js +0 -19
- package/dist/dtos/invoice/invoice-info.dto.d.ts +15 -0
- package/dist/dtos/invoice/invoice-info.dto.js +42 -0
- package/dist/dtos/invoice/invoice-item-data.dto.d.ts +10 -0
- package/dist/dtos/invoice/invoice-item-data.dto.js +34 -0
- package/dist/dtos/invoice/requests/credit-note-request.dto.d.ts +9 -0
- package/dist/dtos/invoice/requests/credit-note-request.dto.js +32 -0
- package/dist/dtos/invoice/requests/invoice-request.dto.d.ts +9 -0
- package/dist/dtos/invoice/requests/invoice-request.dto.js +32 -0
- package/dist/dtos/invoice/requests/proforma-invoice-request.dto.d.ts +24 -0
- package/dist/dtos/invoice/requests/proforma-invoice-request.dto.js +104 -0
- package/dist/dtos/invoice/requests/tax-details-request.dto.d.ts +31 -0
- package/dist/dtos/invoice/requests/tax-details-request.dto.js +84 -0
- package/dist/dtos/invoice/responses/credit-note-response.dto.d.ts +7 -0
- package/dist/dtos/invoice/responses/credit-note-response.dto.js +11 -0
- package/dist/dtos/invoice/responses/invoice-response.dto.d.ts +7 -0
- package/dist/dtos/invoice/responses/invoice-response.dto.js +11 -0
- package/dist/dtos/invoice/responses/proforma-invoice-response.dto.d.ts +12 -0
- package/dist/dtos/invoice/responses/proforma-invoice-response.dto.js +52 -0
- package/dist/dtos/invoice/responses/tax-details-response.dto.d.ts +20 -0
- package/dist/dtos/invoice/responses/tax-details-response.dto.js +56 -0
- package/dist/dtos/invoice/tin-validation-details.dto.d.ts +51 -0
- package/dist/dtos/invoice/tin-validation-details.dto.js +165 -0
- package/dist/dtos/invoice/transaction-data.dto.d.ts +14 -0
- package/dist/dtos/invoice/transaction-data.dto.js +64 -0
- package/dist/dtos/invoice-contact-data.dto.d.ts +43 -0
- package/dist/dtos/invoice-contact-data.dto.js +222 -0
- package/dist/dtos/item-data.dto.d.ts +44 -0
- package/dist/dtos/item-data.dto.js +131 -0
- package/dist/dtos/jwt.dto.js +27 -0
- package/dist/dtos/multilang-text.dto.js +12 -0
- package/dist/dtos/notification/receiver/receiver-email.dto.js +19 -0
- package/dist/dtos/notification/receiver/receiver-sms.dto.js +7 -0
- package/dist/dtos/notification/requests/notification-send-request.dto.d.ts +18 -0
- package/dist/dtos/notification/requests/notification-send-request.dto.js +90 -0
- package/dist/dtos/notification/responses/notification-send-response.dto.d.ts +9 -0
- package/dist/dtos/notification/responses/notification-send-response.dto.js +32 -0
- package/dist/dtos/notification/sender/sender-email.dto.js +26 -0
- package/dist/dtos/notification/sender/sender-push.dto.js +36 -0
- package/dist/dtos/notification/sender/sender-sms.dto.js +11 -0
- package/dist/dtos/product/product-info.dto.d.ts +8 -3
- package/dist/dtos/product/product-info.dto.js +25 -5
- package/dist/dtos/product/product-item-data.dto.d.ts +7 -28
- package/dist/dtos/product/product-item-data.dto.js +14 -23
- package/dist/dtos/product/requests/product-create-request.dto.js +11 -0
- package/dist/dtos/product/requests/product-delete-request.dto.js +11 -0
- package/dist/dtos/product/requests/product-downgradable-request.dto.js +11 -0
- package/dist/dtos/product/requests/product-downgrade-request.dto.js +16 -0
- package/dist/dtos/product/requests/product-renew-request.dto.js +11 -0
- package/dist/dtos/product/requests/product-suspend-request.dto.js +11 -0
- package/dist/dtos/product/requests/product-unsuspend-request.dto.js +11 -0
- package/dist/dtos/product/requests/product-upgradable-request.dto.js +11 -0
- package/dist/dtos/product/requests/product-upgrade-request.dto.js +16 -0
- package/dist/dtos/product/responses/product-create-response.dto.js +37 -0
- package/dist/dtos/product/responses/product-delete-response.dto.js +37 -0
- package/dist/dtos/product/responses/product-downgradable-response.dto.js +37 -0
- package/dist/dtos/product/responses/product-downgrade-response.dto.js +37 -0
- package/dist/dtos/product/responses/product-info-response.dto.js +23 -0
- package/dist/dtos/product/responses/product-renew-response.dto.js +37 -0
- package/dist/dtos/product/responses/product-suspend-response.dto.js +37 -0
- package/dist/dtos/product/responses/product-unsuspend-response.dto.js +37 -0
- package/dist/dtos/product/responses/product-upgradable-response.dto.js +37 -0
- package/dist/dtos/product/responses/product-upgrade-response.dto.js +37 -0
- package/dist/dtos/requests/validate-attributes-request.dto.js +12 -0
- package/dist/dtos/response-data.dto.js +19 -0
- package/dist/dtos/responses/validate-attributes-response.dto.js +25 -0
- package/dist/dtos/settings.dto.d.ts +18 -0
- package/dist/dtos/settings.dto.js +19 -2
- package/dist/dtos/setup-status-response.dto.js +20 -0
- package/dist/dtos/success-response.dto.d.ts +0 -4
- package/dist/dtos/success-response.dto.js +0 -14
- package/dist/enums/invoice/invoice-item-actions.enum.d.ts +8 -0
- package/dist/enums/invoice/invoice-item-actions.enum.js +12 -0
- package/dist/enums/invoice/invoice-types.enum.d.ts +5 -0
- package/dist/enums/invoice/invoice-types.enum.js +9 -0
- package/dist/enums/item-actions.enum.d.ts +11 -0
- package/dist/enums/item-actions.enum.js +16 -0
- package/dist/index.d.ts +36 -5
- package/dist/index.js +37 -7
- package/dist/openapi/schemas/components.schemas.d.ts +152 -49
- package/dist/openapi/schemas/components.schemas.js +191 -89
- package/dist/validators/addon-field-validator.d.ts +9 -0
- package/dist/validators/addon-field-validator.js +14 -0
- package/dist/validators/addon-field-validator.spec.d.ts +1 -0
- package/dist/validators/addon-field-validator.spec.js +38 -0
- package/dist/validators/attachment-validator.d.ts +8 -0
- package/dist/validators/attachment-validator.js +17 -0
- package/dist/validators/attachment-validator.spec.d.ts +1 -0
- package/dist/validators/attachment-validator.spec.js +58 -0
- package/dist/validators/attribute-field-validator.d.ts +8 -0
- package/dist/validators/attribute-field-validator.js +17 -0
- package/dist/validators/attribute-field-validator.spec.d.ts +1 -0
- package/dist/validators/attribute-field-validator.spec.js +84 -0
- package/dist/validators/country-validator.d.ts +8 -0
- package/dist/validators/country-validator.js +17 -0
- package/dist/validators/country-validator.spec.d.ts +1 -0
- package/dist/validators/country-validator.spec.js +58 -0
- package/dist/validators/field-validator.spec.js +1 -29
- package/dist/validators/info-validator.d.ts +8 -0
- package/dist/validators/info-validator.js +17 -0
- package/dist/validators/info-validator.spec.d.ts +1 -0
- package/dist/validators/info-validator.spec.js +85 -0
- package/dist/validators/invoice-contact-data-validator.d.ts +8 -0
- package/dist/validators/invoice-contact-data-validator.js +17 -0
- package/dist/validators/invoice-contact-data-validator.spec.d.ts +1 -0
- package/dist/validators/invoice-contact-data-validator.spec.js +88 -0
- package/dist/validators/invoice-info-validator.d.ts +8 -0
- package/dist/validators/invoice-info-validator.js +17 -0
- package/dist/validators/invoice-info-validator.spec.d.ts +1 -0
- package/dist/validators/invoice-info-validator.spec.js +81 -0
- package/dist/validators/invoice-item-data-validator.d.ts +8 -0
- package/dist/validators/invoice-item-data-validator.js +17 -0
- package/dist/validators/invoice-item-data-validator.spec.d.ts +1 -0
- package/dist/validators/invoice-item-data-validator.spec.js +45 -0
- package/dist/validators/item-data-validator.d.ts +8 -0
- package/dist/validators/item-data-validator.js +17 -0
- package/dist/validators/item-data-validator.spec.d.ts +1 -0
- package/dist/validators/item-data-validator.spec.js +79 -0
- package/dist/validators/notification-info-validator.spec.js +6 -6
- package/dist/validators/notification-request-validator.js +2 -2
- package/dist/validators/product-create-request-validator.js +1 -1
- package/dist/validators/product-delete-request-validator.js +1 -1
- package/dist/validators/product-downgradable-request-validator.js +1 -1
- package/dist/validators/product-downgrade-request-validator.js +1 -1
- package/dist/validators/product-info-validator.spec.js +20 -28
- package/dist/validators/product-item-data-validator.d.ts +8 -0
- package/dist/validators/product-item-data-validator.js +17 -0
- package/dist/validators/product-item-data-validator.spec.d.ts +1 -0
- package/dist/validators/product-item-data-validator.spec.js +60 -0
- package/dist/validators/product-renew-request-validator.js +1 -1
- package/dist/validators/product-suspend-request-validator.js +1 -1
- package/dist/validators/product-unsuspend-request-validator.js +1 -1
- package/dist/validators/product-upgradable-request-validator.js +1 -1
- package/dist/validators/product-upgrade-request-validator.js +1 -1
- package/dist/validators/tab-validator.d.ts +8 -0
- package/dist/validators/tab-validator.js +17 -0
- package/dist/validators/tab-validator.spec.d.ts +1 -0
- package/dist/validators/tab-validator.spec.js +49 -0
- package/dist/validators/tin-validation-details-validator.d.ts +8 -0
- package/dist/validators/tin-validation-details-validator.js +17 -0
- package/dist/validators/tin-validation-details-validator.spec.d.ts +1 -0
- package/dist/validators/tin-validation-details-validator.spec.js +77 -0
- package/dist/validators/transaction-data-validator.d.ts +8 -0
- package/dist/validators/transaction-data-validator.js +17 -0
- package/dist/validators/transaction-data-validator.spec.d.ts +1 -0
- package/dist/validators/transaction-data-validator.spec.js +62 -0
- package/package.json +1 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("reflect-metadata");
|
|
4
|
+
const invoice_item_data_validator_1 = require("./invoice-item-data-validator");
|
|
5
|
+
const invoice_item_actions_enum_1 = require("../enums/invoice/invoice-item-actions.enum");
|
|
6
|
+
const baseValidDto = {
|
|
7
|
+
productId: 'prod-123',
|
|
8
|
+
productName: 'Web Hosting',
|
|
9
|
+
resourceName: 'hosting-basic',
|
|
10
|
+
productAttributes: { plan: 'basic' },
|
|
11
|
+
itemAttributes: { domain: 'example.com' },
|
|
12
|
+
startDate: '2025-01-01',
|
|
13
|
+
endDate: '2025-12-31',
|
|
14
|
+
action: invoice_item_actions_enum_1.InvoiceItemActionsEnum.CREATE,
|
|
15
|
+
};
|
|
16
|
+
describe('InvoiceItemDataDto Validator', () => {
|
|
17
|
+
describe('Valid cases', () => {
|
|
18
|
+
it('should return no errors for a valid DTO', () => {
|
|
19
|
+
expect((0, invoice_item_data_validator_1.validateInvoiceItemDataDto)(baseValidDto)).toHaveLength(0);
|
|
20
|
+
});
|
|
21
|
+
it.each(Object.values(invoice_item_actions_enum_1.InvoiceItemActionsEnum))('should accept action %s', (action) => {
|
|
22
|
+
const dto = { ...baseValidDto, action };
|
|
23
|
+
expect((0, invoice_item_data_validator_1.validateInvoiceItemDataDto)(dto)).toHaveLength(0);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
describe('Missing required fields', () => {
|
|
27
|
+
it('should return error when action is missing', () => {
|
|
28
|
+
const { action, ...dto } = baseValidDto;
|
|
29
|
+
const errors = (0, invoice_item_data_validator_1.validateInvoiceItemDataDto)(dto);
|
|
30
|
+
expect(errors.some(e => e.property === 'action')).toBe(true);
|
|
31
|
+
});
|
|
32
|
+
it('should return errors for inherited required fields when missing', () => {
|
|
33
|
+
const errors = (0, invoice_item_data_validator_1.validateInvoiceItemDataDto)({});
|
|
34
|
+
expect(errors.some(e => e.property === 'action')).toBe(true);
|
|
35
|
+
expect(errors.some(e => e.property === 'productId')).toBe(true);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
describe('Invalid field values', () => {
|
|
39
|
+
it('should return error for invalid action enum', () => {
|
|
40
|
+
const dto = { ...baseValidDto, action: 'invalid-action' };
|
|
41
|
+
const errors = (0, invoice_item_data_validator_1.validateInvoiceItemDataDto)(dto);
|
|
42
|
+
expect(errors.some(e => e.property === 'action')).toBe(true);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ValidationError } from 'class-validator';
|
|
2
|
+
/**
|
|
3
|
+
* Validates an ItemDataDto object using class-validator decorators.
|
|
4
|
+
*
|
|
5
|
+
* @param data The object to validate as an ItemDataDto.
|
|
6
|
+
* @returns An array of validation errors, empty if validation succeeds.
|
|
7
|
+
*/
|
|
8
|
+
export declare function validateItemDataDto(data: object): ValidationError[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateItemDataDto = validateItemDataDto;
|
|
4
|
+
const class_validator_1 = require("class-validator");
|
|
5
|
+
const class_transformer_1 = require("class-transformer");
|
|
6
|
+
const item_data_dto_1 = require("../dtos/item-data.dto");
|
|
7
|
+
/**
|
|
8
|
+
* Validates an ItemDataDto object using class-validator decorators.
|
|
9
|
+
*
|
|
10
|
+
* @param data The object to validate as an ItemDataDto.
|
|
11
|
+
* @returns An array of validation errors, empty if validation succeeds.
|
|
12
|
+
*/
|
|
13
|
+
function validateItemDataDto(data) {
|
|
14
|
+
const dto = (0, class_transformer_1.plainToInstance)(item_data_dto_1.ItemDataDto, data);
|
|
15
|
+
const errors = (0, class_validator_1.validateSync)(dto);
|
|
16
|
+
return errors;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("reflect-metadata");
|
|
4
|
+
const item_data_validator_1 = require("./item-data-validator");
|
|
5
|
+
const baseValidDto = {
|
|
6
|
+
productId: 'prod-123',
|
|
7
|
+
productName: 'Web Hosting',
|
|
8
|
+
resourceName: 'hosting-basic',
|
|
9
|
+
productAttributes: { plan: 'basic' },
|
|
10
|
+
itemAttributes: { domain: 'example.com' },
|
|
11
|
+
startDate: '2025-01-01',
|
|
12
|
+
endDate: '2025-12-31',
|
|
13
|
+
};
|
|
14
|
+
describe('ItemDataDto Validator', () => {
|
|
15
|
+
describe('Valid cases', () => {
|
|
16
|
+
it('should return no errors for a valid DTO', () => {
|
|
17
|
+
expect((0, item_data_validator_1.validateItemDataDto)(baseValidDto)).toHaveLength(0);
|
|
18
|
+
});
|
|
19
|
+
it('should return no errors with optional fields', () => {
|
|
20
|
+
const dto = {
|
|
21
|
+
...baseValidDto,
|
|
22
|
+
itemId: 'item-456',
|
|
23
|
+
creationResponseData: { externalId: 'ext-1' },
|
|
24
|
+
price: 9.99,
|
|
25
|
+
discountPrice: 7.99,
|
|
26
|
+
};
|
|
27
|
+
expect((0, item_data_validator_1.validateItemDataDto)(dto)).toHaveLength(0);
|
|
28
|
+
});
|
|
29
|
+
it('should return no errors when optional fields are omitted', () => {
|
|
30
|
+
expect((0, item_data_validator_1.validateItemDataDto)(baseValidDto)).toHaveLength(0);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
describe('Missing required fields', () => {
|
|
34
|
+
it('should return errors when all fields are missing', () => {
|
|
35
|
+
const errors = (0, item_data_validator_1.validateItemDataDto)({});
|
|
36
|
+
const requiredProps = ['productId', 'productName', 'resourceName', 'productAttributes', 'itemAttributes', 'startDate', 'endDate'];
|
|
37
|
+
for (const prop of requiredProps) {
|
|
38
|
+
expect(errors.some(e => e.property === prop)).toBe(true);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
it('should return error when productId is missing', () => {
|
|
42
|
+
const { productId, ...dto } = baseValidDto;
|
|
43
|
+
const errors = (0, item_data_validator_1.validateItemDataDto)(dto);
|
|
44
|
+
expect(errors.some(e => e.property === 'productId')).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
it('should return error when productAttributes is missing', () => {
|
|
47
|
+
const { productAttributes, ...dto } = baseValidDto;
|
|
48
|
+
const errors = (0, item_data_validator_1.validateItemDataDto)(dto);
|
|
49
|
+
expect(errors.some(e => e.property === 'productAttributes')).toBe(true);
|
|
50
|
+
});
|
|
51
|
+
it('should return error when itemAttributes is missing', () => {
|
|
52
|
+
const { itemAttributes, ...dto } = baseValidDto;
|
|
53
|
+
const errors = (0, item_data_validator_1.validateItemDataDto)(dto);
|
|
54
|
+
expect(errors.some(e => e.property === 'itemAttributes')).toBe(true);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
describe('Invalid field values', () => {
|
|
58
|
+
it('should return error for empty productId', () => {
|
|
59
|
+
const dto = { ...baseValidDto, productId: '' };
|
|
60
|
+
const errors = (0, item_data_validator_1.validateItemDataDto)(dto);
|
|
61
|
+
expect(errors.some(e => e.property === 'productId')).toBe(true);
|
|
62
|
+
});
|
|
63
|
+
it('should return error for empty startDate', () => {
|
|
64
|
+
const dto = { ...baseValidDto, startDate: '' };
|
|
65
|
+
const errors = (0, item_data_validator_1.validateItemDataDto)(dto);
|
|
66
|
+
expect(errors.some(e => e.property === 'startDate')).toBe(true);
|
|
67
|
+
});
|
|
68
|
+
it('should return error for non-number price', () => {
|
|
69
|
+
const dto = { ...baseValidDto, price: 'free' };
|
|
70
|
+
const errors = (0, item_data_validator_1.validateItemDataDto)(dto);
|
|
71
|
+
expect(errors.some(e => e.property === 'price')).toBe(true);
|
|
72
|
+
});
|
|
73
|
+
it('should return error for non-number discountPrice', () => {
|
|
74
|
+
const dto = { ...baseValidDto, discountPrice: 'half-off' };
|
|
75
|
+
const errors = (0, item_data_validator_1.validateItemDataDto)(dto);
|
|
76
|
+
expect(errors.some(e => e.property === 'discountPrice')).toBe(true);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
});
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
require("reflect-metadata");
|
|
4
4
|
const notification_info_validator_1 = require("./notification-info.validator");
|
|
5
5
|
const notification_message_type_enum_1 = require("../enums/notification/notification-message-type.enum");
|
|
6
|
-
const
|
|
6
|
+
const item_actions_enum_1 = require("../enums/item-actions.enum");
|
|
7
7
|
const language_enum_1 = require("../enums/language.enum");
|
|
8
8
|
describe('NotificationInfoDto Validator', () => {
|
|
9
9
|
const validUnit = { id: "ram", unitDescription: "MB", intervalDescription: "month" };
|
|
@@ -13,7 +13,7 @@ describe('NotificationInfoDto Validator', () => {
|
|
|
13
13
|
dto: {
|
|
14
14
|
type: notification_message_type_enum_1.NotificationMessageTypeEnum.EMAIL,
|
|
15
15
|
title: 'Valid Title',
|
|
16
|
-
supportedActions: [
|
|
16
|
+
supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
|
|
17
17
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
18
18
|
payPerUseUnits: [validUnit]
|
|
19
19
|
},
|
|
@@ -23,7 +23,7 @@ describe('NotificationInfoDto Validator', () => {
|
|
|
23
23
|
description: 'should return error for missing type',
|
|
24
24
|
dto: {
|
|
25
25
|
title: 'Valid Title',
|
|
26
|
-
supportedActions: [
|
|
26
|
+
supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
|
|
27
27
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
28
28
|
payPerUseUnits: [validUnit]
|
|
29
29
|
},
|
|
@@ -34,7 +34,7 @@ describe('NotificationInfoDto Validator', () => {
|
|
|
34
34
|
dto: {
|
|
35
35
|
type: notification_message_type_enum_1.NotificationMessageTypeEnum.EMAIL,
|
|
36
36
|
title: 'Valid Title',
|
|
37
|
-
supportedActions: [
|
|
37
|
+
supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
|
|
38
38
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
39
39
|
payPerUseUnits: [{ id: "", unitDescription: "", intervalDescription: "" }] // Invalid unit
|
|
40
40
|
},
|
|
@@ -52,7 +52,7 @@ describe('NotificationInfoDto Validator', () => {
|
|
|
52
52
|
description: 'should return ValidationError for missing title',
|
|
53
53
|
dto: {
|
|
54
54
|
type: notification_message_type_enum_1.NotificationMessageTypeEnum.EMAIL,
|
|
55
|
-
supportedActions: [
|
|
55
|
+
supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
|
|
56
56
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
57
57
|
payPerUseUnits: [validUnit]
|
|
58
58
|
},
|
|
@@ -63,7 +63,7 @@ describe('NotificationInfoDto Validator', () => {
|
|
|
63
63
|
dto: {
|
|
64
64
|
type: notification_message_type_enum_1.NotificationMessageTypeEnum.EMAIL,
|
|
65
65
|
title: 'Valid Title',
|
|
66
|
-
supportedActions: [
|
|
66
|
+
supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
|
|
67
67
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
68
68
|
payPerUseUnits: [{ id: "", unitDescription: "", intervalDescription: "" }]
|
|
69
69
|
},
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.validateNotificationRequestDto = validateNotificationRequestDto;
|
|
4
4
|
const class_validator_1 = require("class-validator");
|
|
5
5
|
const class_transformer_1 = require("class-transformer");
|
|
6
|
-
const notification_send_request_dto_1 = require("../dtos/notification/notification-send-request.dto");
|
|
6
|
+
const notification_send_request_dto_1 = require("../dtos/notification/requests/notification-send-request.dto");
|
|
7
7
|
/**
|
|
8
8
|
* Validates a NotificationRequestDto object using class-validator decorators.
|
|
9
9
|
*
|
|
@@ -12,6 +12,6 @@ const notification_send_request_dto_1 = require("../dtos/notification/notificati
|
|
|
12
12
|
*/
|
|
13
13
|
function validateNotificationRequestDto(data) {
|
|
14
14
|
const dto = (0, class_transformer_1.plainToInstance)(notification_send_request_dto_1.NotificationSendRequestDto, data);
|
|
15
|
-
const errors = (0, class_validator_1.validateSync)(dto);
|
|
15
|
+
const errors = (0, class_validator_1.validateSync)(dto, { forbidUnknownValues: false });
|
|
16
16
|
return errors;
|
|
17
17
|
}
|
|
@@ -12,6 +12,6 @@ const product_create_request_dto_1 = require("../dtos/product/requests/product-c
|
|
|
12
12
|
*/
|
|
13
13
|
const validateProductCreateRequestDto = async (plainObject) => {
|
|
14
14
|
const request = (0, class_transformer_1.plainToInstance)(product_create_request_dto_1.ProductCreateRequestDto, plainObject);
|
|
15
|
-
return await (0, class_validator_1.validate)(request);
|
|
15
|
+
return await (0, class_validator_1.validate)(request, { skipMissingProperties: true });
|
|
16
16
|
};
|
|
17
17
|
exports.validateProductCreateRequestDto = validateProductCreateRequestDto;
|
|
@@ -12,6 +12,6 @@ const product_delete_request_dto_1 = require("../dtos/product/requests/product-d
|
|
|
12
12
|
*/
|
|
13
13
|
const validateProductDeleteRequestDto = async (plainObject) => {
|
|
14
14
|
const request = (0, class_transformer_1.plainToInstance)(product_delete_request_dto_1.ProductDeleteRequestDto, plainObject);
|
|
15
|
-
return await (0, class_validator_1.validate)(request);
|
|
15
|
+
return await (0, class_validator_1.validate)(request, { skipMissingProperties: true });
|
|
16
16
|
};
|
|
17
17
|
exports.validateProductDeleteRequestDto = validateProductDeleteRequestDto;
|
|
@@ -12,6 +12,6 @@ const product_downgradable_request_dto_1 = require("../dtos/product/requests/pro
|
|
|
12
12
|
*/
|
|
13
13
|
const validateProductDowngradableRequestDto = async (plainObject) => {
|
|
14
14
|
const request = (0, class_transformer_1.plainToInstance)(product_downgradable_request_dto_1.ProductDowngradableRequestDto, plainObject);
|
|
15
|
-
return await (0, class_validator_1.validate)(request);
|
|
15
|
+
return await (0, class_validator_1.validate)(request, { skipMissingProperties: true });
|
|
16
16
|
};
|
|
17
17
|
exports.validateProductDowngradableRequestDto = validateProductDowngradableRequestDto;
|
|
@@ -12,6 +12,6 @@ const product_downgrade_request_dto_1 = require("../dtos/product/requests/produc
|
|
|
12
12
|
*/
|
|
13
13
|
const validateProductDowngradeRequestDto = async (plainObject) => {
|
|
14
14
|
const request = (0, class_transformer_1.plainToInstance)(product_downgrade_request_dto_1.ProductDowngradeRequestDto, plainObject);
|
|
15
|
-
return await (0, class_validator_1.validate)(request);
|
|
15
|
+
return await (0, class_validator_1.validate)(request, { skipMissingProperties: true });
|
|
16
16
|
};
|
|
17
17
|
exports.validateProductDowngradeRequestDto = validateProductDowngradeRequestDto;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
require("reflect-metadata");
|
|
4
4
|
// import { ProductInfoDto } from '../dtos/product/product-info.dto';
|
|
5
|
-
const
|
|
5
|
+
const item_actions_enum_1 = require("../enums/item-actions.enum");
|
|
6
6
|
const language_enum_1 = require("../enums/language.enum");
|
|
7
7
|
const field_type_enum_1 = require("../enums/field-type.enum");
|
|
8
8
|
const product_info_validator_1 = require("./product-info.validator");
|
|
@@ -14,8 +14,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
14
14
|
type: field_type_enum_1.FieldTypeEnum.TEXT_BOX,
|
|
15
15
|
required: false,
|
|
16
16
|
disabled: false,
|
|
17
|
-
|
|
18
|
-
visibleInClientPanel: true,
|
|
17
|
+
hidden: false,
|
|
19
18
|
upgradable: false
|
|
20
19
|
};
|
|
21
20
|
const invalidField = {
|
|
@@ -31,7 +30,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
31
30
|
description: 'should return no errors for valid DTO',
|
|
32
31
|
dto: {
|
|
33
32
|
title: 'Test',
|
|
34
|
-
supportedActions: [
|
|
33
|
+
supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
|
|
35
34
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
36
35
|
productAttributes: [field],
|
|
37
36
|
itemAttributes: [field]
|
|
@@ -42,7 +41,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
42
41
|
description: 'should return error for invalid required and hidden',
|
|
43
42
|
dto: {
|
|
44
43
|
title: 'Test',
|
|
45
|
-
supportedActions: [
|
|
44
|
+
supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
|
|
46
45
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
47
46
|
itemAttributes: [invalidField]
|
|
48
47
|
},
|
|
@@ -52,7 +51,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
52
51
|
description: 'should return error for invalid title',
|
|
53
52
|
dto: {
|
|
54
53
|
title: '',
|
|
55
|
-
supportedActions: [
|
|
54
|
+
supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
|
|
56
55
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
57
56
|
productAttributes: [field],
|
|
58
57
|
itemAttributes: [field]
|
|
@@ -74,7 +73,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
74
73
|
description: 'should return error for unsupported language',
|
|
75
74
|
dto: {
|
|
76
75
|
title: 'Test',
|
|
77
|
-
supportedActions: [
|
|
76
|
+
supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
|
|
78
77
|
supportedLanguages: [],
|
|
79
78
|
productAttributes: [field],
|
|
80
79
|
itemAttributes: [field]
|
|
@@ -85,7 +84,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
85
84
|
description: 'should return no errors for valid DTO with adminPanel and clientPanel',
|
|
86
85
|
dto: {
|
|
87
86
|
title: 'Test',
|
|
88
|
-
supportedActions: [
|
|
87
|
+
supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
|
|
89
88
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
90
89
|
productAttributes: [field],
|
|
91
90
|
itemAttributes: [field],
|
|
@@ -98,7 +97,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
98
97
|
description: 'should return error for invalid DTO with adminPanel and clientPanel',
|
|
99
98
|
dto: {
|
|
100
99
|
title: '',
|
|
101
|
-
supportedActions: [
|
|
100
|
+
supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
|
|
102
101
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
103
102
|
productAttributes: [field],
|
|
104
103
|
itemAttributes: [field],
|
|
@@ -111,7 +110,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
111
110
|
description: 'should return no errors for valid DTO with payPerUseUnits',
|
|
112
111
|
dto: {
|
|
113
112
|
title: 'Test',
|
|
114
|
-
supportedActions: [
|
|
113
|
+
supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
|
|
115
114
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
116
115
|
productAttributes: [field],
|
|
117
116
|
itemAttributes: [field],
|
|
@@ -123,7 +122,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
123
122
|
description: 'should return error for invalid DTO with payPerUseUnits',
|
|
124
123
|
dto: {
|
|
125
124
|
title: 'Test',
|
|
126
|
-
supportedActions: [
|
|
125
|
+
supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
|
|
127
126
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
128
127
|
productAttributes: [field],
|
|
129
128
|
itemAttributes: [field],
|
|
@@ -142,7 +141,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
142
141
|
{
|
|
143
142
|
description: 'should return ValidationError for missing title',
|
|
144
143
|
dto: {
|
|
145
|
-
supportedActions: [
|
|
144
|
+
supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
|
|
146
145
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
147
146
|
productAttributes: [field],
|
|
148
147
|
itemAttributes: [field]
|
|
@@ -179,14 +178,13 @@ describe('ProductInfoDto Validator', () => {
|
|
|
179
178
|
type: field_type_enum_1.FieldTypeEnum.TEXT_BOX,
|
|
180
179
|
required: false,
|
|
181
180
|
disabled: false,
|
|
182
|
-
|
|
183
|
-
visibleInClientPanel: true,
|
|
181
|
+
hidden: false,
|
|
184
182
|
upgradable: false,
|
|
185
183
|
repeatableMin: 1,
|
|
186
184
|
};
|
|
187
185
|
const dto = {
|
|
188
186
|
title: 'Test',
|
|
189
|
-
supportedActions: [
|
|
187
|
+
supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
|
|
190
188
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
191
189
|
productAttributes: [fieldWithOnlyMin],
|
|
192
190
|
};
|
|
@@ -201,14 +199,13 @@ describe('ProductInfoDto Validator', () => {
|
|
|
201
199
|
type: field_type_enum_1.FieldTypeEnum.TEXT_BOX,
|
|
202
200
|
required: false,
|
|
203
201
|
disabled: false,
|
|
204
|
-
visibleInOrder: false,
|
|
205
|
-
visibleInClientPanel: true,
|
|
206
202
|
upgradable: false,
|
|
207
|
-
|
|
203
|
+
hidden: false,
|
|
204
|
+
repeatableMax: 5,
|
|
208
205
|
};
|
|
209
206
|
const dto = {
|
|
210
207
|
title: 'Test',
|
|
211
|
-
supportedActions: [
|
|
208
|
+
supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
|
|
212
209
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
213
210
|
itemAttributes: [fieldWithOnlyMax],
|
|
214
211
|
};
|
|
@@ -223,15 +220,11 @@ describe('ProductInfoDto Validator', () => {
|
|
|
223
220
|
type: field_type_enum_1.FieldTypeEnum.TEXT_BOX,
|
|
224
221
|
required: false,
|
|
225
222
|
disabled: false,
|
|
226
|
-
|
|
227
|
-
visibleInClientPanel: true,
|
|
228
|
-
upgradable: false,
|
|
229
|
-
repeatableMin: 1,
|
|
230
|
-
repeatableMax: 2,
|
|
223
|
+
hidden: false,
|
|
231
224
|
};
|
|
232
225
|
const dto = {
|
|
233
226
|
title: 'Test',
|
|
234
|
-
supportedActions: [
|
|
227
|
+
supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
|
|
235
228
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
236
229
|
productAttributes: [fieldOk],
|
|
237
230
|
};
|
|
@@ -245,15 +238,14 @@ describe('ProductInfoDto Validator', () => {
|
|
|
245
238
|
type: field_type_enum_1.FieldTypeEnum.TEXT_BOX,
|
|
246
239
|
required: false,
|
|
247
240
|
disabled: false,
|
|
248
|
-
|
|
249
|
-
visibleInClientPanel: true,
|
|
241
|
+
hidden: false,
|
|
250
242
|
upgradable: false,
|
|
251
243
|
repeatableMin: 5,
|
|
252
244
|
repeatableMax: 2,
|
|
253
245
|
};
|
|
254
246
|
const dto = {
|
|
255
247
|
title: 'Test',
|
|
256
|
-
supportedActions: [
|
|
248
|
+
supportedActions: [item_actions_enum_1.ProductItemActionsEnum.CREATE],
|
|
257
249
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
258
250
|
itemAttributes: [fieldBad],
|
|
259
251
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ValidationError } from 'class-validator';
|
|
2
|
+
/**
|
|
3
|
+
* Validates a ProductItemDataDto object using class-validator decorators.
|
|
4
|
+
*
|
|
5
|
+
* @param data The object to validate as a ProductItemDataDto.
|
|
6
|
+
* @returns An array of validation errors, empty if validation succeeds.
|
|
7
|
+
*/
|
|
8
|
+
export declare function validateProductItemDataDto(data: object): ValidationError[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateProductItemDataDto = validateProductItemDataDto;
|
|
4
|
+
const class_validator_1 = require("class-validator");
|
|
5
|
+
const class_transformer_1 = require("class-transformer");
|
|
6
|
+
const product_item_data_dto_1 = require("../dtos/product/product-item-data.dto");
|
|
7
|
+
/**
|
|
8
|
+
* Validates a ProductItemDataDto object using class-validator decorators.
|
|
9
|
+
*
|
|
10
|
+
* @param data The object to validate as a ProductItemDataDto.
|
|
11
|
+
* @returns An array of validation errors, empty if validation succeeds.
|
|
12
|
+
*/
|
|
13
|
+
function validateProductItemDataDto(data) {
|
|
14
|
+
const dto = (0, class_transformer_1.plainToInstance)(product_item_data_dto_1.ProductItemDataDto, data);
|
|
15
|
+
const errors = (0, class_validator_1.validateSync)(dto);
|
|
16
|
+
return errors;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("reflect-metadata");
|
|
4
|
+
const product_item_data_validator_1 = require("./product-item-data-validator");
|
|
5
|
+
const item_actions_enum_1 = require("../enums/item-actions.enum");
|
|
6
|
+
const baseValidDto = {
|
|
7
|
+
productId: 'prod-123',
|
|
8
|
+
productName: 'Web Hosting',
|
|
9
|
+
resourceName: 'hosting-basic',
|
|
10
|
+
productAttributes: { plan: 'basic' },
|
|
11
|
+
itemAttributes: { domain: 'example.com' },
|
|
12
|
+
startDate: '2025-01-01',
|
|
13
|
+
endDate: '2025-12-31',
|
|
14
|
+
};
|
|
15
|
+
describe('ProductItemDataDto Validator', () => {
|
|
16
|
+
describe('Valid cases', () => {
|
|
17
|
+
it('should return no errors for a valid DTO without action', () => {
|
|
18
|
+
expect((0, product_item_data_validator_1.validateProductItemDataDto)(baseValidDto)).toHaveLength(0);
|
|
19
|
+
});
|
|
20
|
+
it('should return no errors with a valid action', () => {
|
|
21
|
+
const dto = { ...baseValidDto, action: item_actions_enum_1.ProductItemActionsEnum.CREATE };
|
|
22
|
+
expect((0, product_item_data_validator_1.validateProductItemDataDto)(dto)).toHaveLength(0);
|
|
23
|
+
});
|
|
24
|
+
it.each(Object.values(item_actions_enum_1.ProductItemActionsEnum))('should accept action %s', (action) => {
|
|
25
|
+
const dto = { ...baseValidDto, action };
|
|
26
|
+
expect((0, product_item_data_validator_1.validateProductItemDataDto)(dto)).toHaveLength(0);
|
|
27
|
+
});
|
|
28
|
+
it('should return no errors with optional inherited fields', () => {
|
|
29
|
+
const dto = {
|
|
30
|
+
...baseValidDto,
|
|
31
|
+
itemId: 'item-456',
|
|
32
|
+
price: 9.99,
|
|
33
|
+
discountPrice: 7.99,
|
|
34
|
+
action: item_actions_enum_1.ProductItemActionsEnum.RENEW,
|
|
35
|
+
};
|
|
36
|
+
expect((0, product_item_data_validator_1.validateProductItemDataDto)(dto)).toHaveLength(0);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
describe('Missing inherited required fields', () => {
|
|
40
|
+
it('should return errors when all fields are missing', () => {
|
|
41
|
+
const errors = (0, product_item_data_validator_1.validateProductItemDataDto)({});
|
|
42
|
+
const requiredProps = ['productId', 'productName', 'resourceName', 'productAttributes', 'itemAttributes', 'startDate', 'endDate'];
|
|
43
|
+
for (const prop of requiredProps) {
|
|
44
|
+
expect(errors.some(e => e.property === prop)).toBe(true);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
describe('Invalid field values', () => {
|
|
49
|
+
it('should return error for invalid action enum', () => {
|
|
50
|
+
const dto = { ...baseValidDto, action: 'invalid-action' };
|
|
51
|
+
const errors = (0, product_item_data_validator_1.validateProductItemDataDto)(dto);
|
|
52
|
+
expect(errors.some(e => e.property === 'action')).toBe(true);
|
|
53
|
+
});
|
|
54
|
+
it('should return error for non-string action', () => {
|
|
55
|
+
const dto = { ...baseValidDto, action: 123 };
|
|
56
|
+
const errors = (0, product_item_data_validator_1.validateProductItemDataDto)(dto);
|
|
57
|
+
expect(errors.some(e => e.property === 'action')).toBe(true);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -12,6 +12,6 @@ const product_renew_request_dto_1 = require("../dtos/product/requests/product-re
|
|
|
12
12
|
*/
|
|
13
13
|
const validateProductRenewRequestDto = async (plainObject) => {
|
|
14
14
|
const request = (0, class_transformer_1.plainToInstance)(product_renew_request_dto_1.ProductRenewRequestDto, plainObject);
|
|
15
|
-
return await (0, class_validator_1.validate)(request);
|
|
15
|
+
return await (0, class_validator_1.validate)(request, { skipMissingProperties: true });
|
|
16
16
|
};
|
|
17
17
|
exports.validateProductRenewRequestDto = validateProductRenewRequestDto;
|
|
@@ -12,6 +12,6 @@ const product_suspend_request_dto_1 = require("../dtos/product/requests/product-
|
|
|
12
12
|
*/
|
|
13
13
|
const validateProductSuspendRequestDto = async (plainObject) => {
|
|
14
14
|
const request = (0, class_transformer_1.plainToInstance)(product_suspend_request_dto_1.ProductSuspendRequestDto, plainObject);
|
|
15
|
-
return await (0, class_validator_1.validate)(request);
|
|
15
|
+
return await (0, class_validator_1.validate)(request, { skipMissingProperties: true });
|
|
16
16
|
};
|
|
17
17
|
exports.validateProductSuspendRequestDto = validateProductSuspendRequestDto;
|
|
@@ -12,6 +12,6 @@ const product_unsuspend_request_dto_1 = require("../dtos/product/requests/produc
|
|
|
12
12
|
*/
|
|
13
13
|
const validateProductUnsuspendRequestDto = async (plainObject) => {
|
|
14
14
|
const request = (0, class_transformer_1.plainToInstance)(product_unsuspend_request_dto_1.ProductUnsuspendRequestDto, plainObject);
|
|
15
|
-
return await (0, class_validator_1.validate)(request);
|
|
15
|
+
return await (0, class_validator_1.validate)(request, { skipMissingProperties: true });
|
|
16
16
|
};
|
|
17
17
|
exports.validateProductUnsuspendRequestDto = validateProductUnsuspendRequestDto;
|
|
@@ -12,6 +12,6 @@ const product_upgradable_request_dto_1 = require("../dtos/product/requests/produ
|
|
|
12
12
|
*/
|
|
13
13
|
const validateProductUpgradableRequestDto = async (plainObject) => {
|
|
14
14
|
const request = (0, class_transformer_1.plainToInstance)(product_upgradable_request_dto_1.ProductUpgradableRequestDto, plainObject);
|
|
15
|
-
return await (0, class_validator_1.validate)(request);
|
|
15
|
+
return await (0, class_validator_1.validate)(request, { skipMissingProperties: true });
|
|
16
16
|
};
|
|
17
17
|
exports.validateProductUpgradableRequestDto = validateProductUpgradableRequestDto;
|
|
@@ -12,6 +12,6 @@ const product_upgrade_request_dto_1 = require("../dtos/product/requests/product-
|
|
|
12
12
|
*/
|
|
13
13
|
const validateProductUpgradeRequestDto = async (plainObject) => {
|
|
14
14
|
const request = (0, class_transformer_1.plainToInstance)(product_upgrade_request_dto_1.ProductUpgradeRequestDto, plainObject);
|
|
15
|
-
return await (0, class_validator_1.validate)(request);
|
|
15
|
+
return await (0, class_validator_1.validate)(request, { skipMissingProperties: true });
|
|
16
16
|
};
|
|
17
17
|
exports.validateProductUpgradeRequestDto = validateProductUpgradeRequestDto;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ValidationError } from 'class-validator';
|
|
2
|
+
/**
|
|
3
|
+
* Validates a TabDto object using class-validator decorators.
|
|
4
|
+
*
|
|
5
|
+
* @param data The object to validate as a TabDto.
|
|
6
|
+
* @returns An array of validation errors, empty if validation succeeds.
|
|
7
|
+
*/
|
|
8
|
+
export declare function validateTabDto(data: object): ValidationError[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateTabDto = validateTabDto;
|
|
4
|
+
const class_validator_1 = require("class-validator");
|
|
5
|
+
const class_transformer_1 = require("class-transformer");
|
|
6
|
+
const tab_dto_1 = require("../dtos/tab.dto");
|
|
7
|
+
/**
|
|
8
|
+
* Validates a TabDto object using class-validator decorators.
|
|
9
|
+
*
|
|
10
|
+
* @param data The object to validate as a TabDto.
|
|
11
|
+
* @returns An array of validation errors, empty if validation succeeds.
|
|
12
|
+
*/
|
|
13
|
+
function validateTabDto(data) {
|
|
14
|
+
const dto = (0, class_transformer_1.plainToInstance)(tab_dto_1.TabDto, data);
|
|
15
|
+
const errors = (0, class_validator_1.validateSync)(dto);
|
|
16
|
+
return errors;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'reflect-metadata';
|