@escapenavigator/types 1.10.9 → 1.10.11

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.
@@ -14,6 +14,7 @@ exports.WidgetClientFormDto = void 0;
14
14
  const class_transformer_1 = require("class-transformer");
15
15
  const class_validator_1 = require("class-validator");
16
16
  const openapi_create_preorder_dto_1 = require("../../openapi/orders/openapi-create-preorder.dto");
17
+ const is_major_1 = require("../../shared/is-major");
17
18
  const is_not_blank_1 = require("../../shared/is-not-blank");
18
19
  const widget_booking_filed_enum_1 = require("../../widget/enum/widget-booking-filed.enum");
19
20
  class WidgetClientFormDto {
@@ -44,7 +45,7 @@ __decorate([
44
45
  ], WidgetClientFormDto.prototype, "surname", void 0);
45
46
  __decorate([
46
47
  (0, class_validator_1.ValidateIf)(({ fields }) => fields.includes(widget_booking_filed_enum_1.WidgetBookingFiledEnum.BIRTHDAY)),
47
- (0, is_not_blank_1.IsNotBlank)(),
48
+ (0, is_major_1.IsMajor)(),
48
49
  (0, class_transformer_1.Expose)(),
49
50
  __metadata("design:type", String)
50
51
  ], WidgetClientFormDto.prototype, "birthday", void 0);
@@ -18,5 +18,4 @@ export declare class CreateOrderDto {
18
18
  clientId: number;
19
19
  language?: Languages;
20
20
  comment?: string;
21
- sendNotification: boolean;
22
21
  }
@@ -70,10 +70,4 @@ __decorate([
70
70
  (0, class_transformer_1.Expose)(),
71
71
  __metadata("design:type", String)
72
72
  ], CreateOrderDto.prototype, "comment", void 0);
73
- __decorate([
74
- (0, class_validator_1.IsBoolean)(),
75
- (0, class_transformer_1.Expose)(),
76
- (0, class_transformer_1.Transform)(({ value }) => (value === undefined ? true : value)),
77
- __metadata("design:type", Boolean)
78
- ], CreateOrderDto.prototype, "sendNotification", void 0);
79
73
  exports.CreateOrderDto = CreateOrderDto;
@@ -27,6 +27,7 @@ __decorate([
27
27
  __metadata("design:type", Number)
28
28
  ], CreateNotificationChanelDto.prototype, "userId", void 0);
29
29
  __decorate([
30
+ (0, class_validator_1.ValidateIf)(({ type }) => type !== notification_chanel_type_enum_1.NotificationChanelTypeEnum.CLIENT),
30
31
  (0, is_not_blank_1.IsNotBlank)(),
31
32
  (0, class_transformer_1.Expose)(),
32
33
  __metadata("design:type", String)
@@ -38,7 +39,6 @@ __decorate([
38
39
  ], CreateNotificationChanelDto.prototype, "type", void 0);
39
40
  __decorate([
40
41
  (0, class_validator_1.IsArray)(),
41
- (0, class_validator_1.ArrayMinSize)(1),
42
42
  (0, class_transformer_1.Expose)(),
43
43
  __metadata("design:type", Array)
44
44
  ], CreateNotificationChanelDto.prototype, "notificationTriggers", void 0);
@@ -2,5 +2,6 @@ export declare enum NotificationChanelTypeEnum {
2
2
  TELEGRAM = "telegram",
3
3
  DISCORD = "discord",
4
4
  WEBHOOK = "webhook",
5
- SLACK = "slack"
5
+ SLACK = "slack",
6
+ CLIENT = "client"
6
7
  }
@@ -7,4 +7,5 @@ var NotificationChanelTypeEnum;
7
7
  NotificationChanelTypeEnum["DISCORD"] = "discord";
8
8
  NotificationChanelTypeEnum["WEBHOOK"] = "webhook";
9
9
  NotificationChanelTypeEnum["SLACK"] = "slack";
10
+ NotificationChanelTypeEnum["CLIENT"] = "client";
10
11
  })(NotificationChanelTypeEnum = exports.NotificationChanelTypeEnum || (exports.NotificationChanelTypeEnum = {}));
@@ -0,0 +1,2 @@
1
+ import { ValidationOptions } from 'class-validator';
2
+ export declare function IsMajor(validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IsMajor = void 0;
4
+ const class_validator_1 = require("class-validator");
5
+ function IsMajor(validationOptions) {
6
+ return function (object, propertyName) {
7
+ (0, class_validator_1.registerDecorator)({
8
+ name: 'isMajor',
9
+ target: object.constructor,
10
+ propertyName,
11
+ options: validationOptions,
12
+ validator: {
13
+ validate(value) {
14
+ if (typeof value !== 'string') {
15
+ return false;
16
+ }
17
+ const birthday = new Date(value);
18
+ if (Number.isNaN(birthday.getTime())) {
19
+ return false;
20
+ }
21
+ const today = new Date();
22
+ const age = today.getFullYear() - birthday.getFullYear();
23
+ const monthDifference = today.getMonth() - birthday.getMonth();
24
+ const dayDifference = today.getDate() - birthday.getDate();
25
+ if (monthDifference < 0 || (monthDifference === 0 && dayDifference < 0)) {
26
+ return age - 1 >= 18;
27
+ }
28
+ return age >= 18;
29
+ },
30
+ defaultMessage() {
31
+ return 'Age should be more than 18';
32
+ },
33
+ },
34
+ });
35
+ };
36
+ }
37
+ exports.IsMajor = IsMajor;