resurgence-data 1.0.20 → 1.0.21

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.
@@ -11,10 +11,8 @@ export declare class LoginRequestDTO {
11
11
  export declare class RecoverAccountDTO {
12
12
  emailAddress: string;
13
13
  }
14
- export declare class SendInviteDTO {
15
- billerId: string;
14
+ export declare class MFARequestDTO {
16
15
  emailAddress: string;
17
- role: string;
18
16
  }
19
17
  export declare class ActivationRequestDTO {
20
18
  token: string;
@@ -9,10 +9,11 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.LoginResponseDTO = exports.TwoFactorCreateDTO = exports.TwoFactorAuthRequestDTO = exports.UpdateAuthenticationDTO = exports.ActivationRequestDTO = exports.SendInviteDTO = exports.RecoverAccountDTO = exports.LoginRequestDTO = exports.SignUpDTO = void 0;
12
+ exports.LoginResponseDTO = exports.TwoFactorCreateDTO = exports.TwoFactorAuthRequestDTO = exports.UpdateAuthenticationDTO = exports.ActivationRequestDTO = exports.MFARequestDTO = exports.RecoverAccountDTO = exports.LoginRequestDTO = exports.SignUpDTO = void 0;
13
13
  const class_validator_1 = require("class-validator");
14
14
  const account_type_1 = require("../types/account.type");
15
15
  const custom_validation_1 = require("../validation/custom-validation");
16
+ const swagger_1 = require("@nestjs/swagger");
16
17
  class SignUpDTO {
17
18
  }
18
19
  exports.SignUpDTO = SignUpDTO;
@@ -21,10 +22,12 @@ class LoginRequestDTO {
21
22
  exports.LoginRequestDTO = LoginRequestDTO;
22
23
  __decorate([
23
24
  (0, class_validator_1.IsString)({ message: "Please enter your username / email address" }),
25
+ (0, swagger_1.ApiProperty)({ description: "The email address for the user" }),
24
26
  __metadata("design:type", String)
25
27
  ], LoginRequestDTO.prototype, "emailAddress", void 0);
26
28
  __decorate([
27
29
  (0, class_validator_1.IsString)({ message: "Please enter your password" }),
30
+ (0, swagger_1.ApiProperty)({ description: "The password for the user" }),
28
31
  __metadata("design:type", String)
29
32
  ], LoginRequestDTO.prototype, "password", void 0);
30
33
  class RecoverAccountDTO {
@@ -32,40 +35,35 @@ class RecoverAccountDTO {
32
35
  exports.RecoverAccountDTO = RecoverAccountDTO;
33
36
  __decorate([
34
37
  (0, class_validator_1.IsString)({ message: "Please enter your email address." }),
38
+ (0, swagger_1.ApiProperty)({ description: "The email address for the user" }),
35
39
  __metadata("design:type", String)
36
40
  ], RecoverAccountDTO.prototype, "emailAddress", void 0);
37
- class SendInviteDTO {
41
+ class MFARequestDTO {
38
42
  }
39
- exports.SendInviteDTO = SendInviteDTO;
43
+ exports.MFARequestDTO = MFARequestDTO;
40
44
  __decorate([
41
- (0, class_validator_1.IsUUID)(4, { message: "Please provide a valid merchant / biller identifier" }),
42
- __metadata("design:type", String)
43
- ], SendInviteDTO.prototype, "billerId", void 0);
44
- __decorate([
45
- (0, class_validator_1.IsString)({ message: "Please enter the email address of your invitee" }),
46
- (0, class_validator_1.IsEmail)(undefined, { message: "Please enter a valid email address" }),
47
- __metadata("design:type", String)
48
- ], SendInviteDTO.prototype, "emailAddress", void 0);
49
- __decorate([
50
- (0, class_validator_1.IsString)({ message: "Please enter a valid data type" }),
51
- (0, class_validator_1.IsIn)(account_type_1.accountTypes, { message: "Please select a valid role type" }),
45
+ (0, class_validator_1.IsString)({ message: "Please enter your email address." }),
46
+ (0, swagger_1.ApiProperty)({ description: "The email address for the user" }),
52
47
  __metadata("design:type", String)
53
- ], SendInviteDTO.prototype, "role", void 0);
48
+ ], MFARequestDTO.prototype, "emailAddress", void 0);
54
49
  class ActivationRequestDTO {
55
50
  }
56
51
  exports.ActivationRequestDTO = ActivationRequestDTO;
57
52
  __decorate([
58
53
  (0, class_validator_1.IsString)({ message: "Please provide your activation code" }),
54
+ (0, swagger_1.ApiProperty)({ description: "Token provided in the users email" }),
59
55
  __metadata("design:type", String)
60
56
  ], ActivationRequestDTO.prototype, "token", void 0);
61
57
  __decorate([
62
58
  (0, class_validator_1.IsString)({ message: "Please provide your password" }),
59
+ (0, swagger_1.ApiProperty)({ description: "The password for the user" }),
63
60
  __metadata("design:type", String)
64
61
  ], ActivationRequestDTO.prototype, "password", void 0);
65
62
  __decorate([
66
63
  (0, class_validator_1.IsOptional)(),
67
64
  (0, class_validator_1.IsString)({ message: "Please confirm your password" }),
68
65
  (0, custom_validation_1.isSameAs)("password", { message: "Your passwords to not match. Please check" }),
66
+ (0, swagger_1.ApiProperty)({ description: "Confirmed password from user" }),
69
67
  __metadata("design:type", String)
70
68
  ], ActivationRequestDTO.prototype, "passwordConfirm", void 0);
71
69
  class UpdateAuthenticationDTO {
@@ -92,11 +90,13 @@ exports.TwoFactorAuthRequestDTO = TwoFactorAuthRequestDTO;
92
90
  __decorate([
93
91
  (0, class_validator_1.IsEmail)(undefined, { message: "Please enter a valid email address" }),
94
92
  (0, class_validator_1.IsString)({ message: "Please enter the email address of your invitee" }),
93
+ (0, swagger_1.ApiProperty)({ description: "Email address of the user" }),
95
94
  __metadata("design:type", String)
96
95
  ], TwoFactorAuthRequestDTO.prototype, "emailAddress", void 0);
97
96
  __decorate([
98
97
  (0, class_validator_1.IsString)({ message: "Please provide the 6 character code" }),
99
98
  (0, class_validator_1.Length)(6, 6, { message: "Please enter a 6 character code" }),
99
+ (0, swagger_1.ApiProperty)({ description: "6 digit code provided by the user" }),
100
100
  __metadata("design:type", String)
101
101
  ], TwoFactorAuthRequestDTO.prototype, "token", void 0);
102
102
  class TwoFactorCreateDTO {
@@ -12,49 +12,59 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.RevokeInviteDTO = exports.AcceptInviteInviteDTO = exports.InviteRequestDTO = void 0;
13
13
  const class_validator_1 = require("class-validator");
14
14
  const account_type_1 = require("../types/account.type");
15
+ const swagger_1 = require("@nestjs/swagger");
15
16
  class InviteRequestDTO {
16
17
  }
17
18
  exports.InviteRequestDTO = InviteRequestDTO;
18
19
  __decorate([
19
- (0, class_validator_1.IsString)({ message: "Please enter your invitees first name" }),
20
+ (0, class_validator_1.IsString)({ message: "Could you provide your invitee's first name?" }),
21
+ (0, swagger_1.ApiProperty)({ description: "First name of the invitee" }),
20
22
  __metadata("design:type", String)
21
23
  ], InviteRequestDTO.prototype, "firstName", void 0);
22
24
  __decorate([
23
- (0, class_validator_1.IsString)({ message: "Please enter your invitees first name" }),
25
+ (0, class_validator_1.IsString)({ message: "Could you provide your invitee's last name?" }),
26
+ (0, swagger_1.ApiProperty)({ description: "Last name of the invitee" }),
24
27
  __metadata("design:type", String)
25
28
  ], InviteRequestDTO.prototype, "lastName", void 0);
26
29
  __decorate([
27
- (0, class_validator_1.IsEmail)(undefined, { message: "Please enter a valid email address" }),
28
- (0, class_validator_1.IsString)({ message: "Please enter your invitees first name" }),
30
+ (0, class_validator_1.IsEmail)(undefined, { message: "Hmm, that doesn't look like a valid email. Could you double-check it?" }),
31
+ (0, class_validator_1.IsString)({ message: "We need your invitee's email address. Please provide it." }),
32
+ (0, swagger_1.ApiProperty)({ description: "Email address of the invitee" }),
29
33
  __metadata("design:type", String)
30
34
  ], InviteRequestDTO.prototype, "emailAddress", void 0);
31
35
  __decorate([
32
- (0, class_validator_1.IsIn)(account_type_1.accountTypes, { message: "Please select a valid role tyoe" }),
36
+ (0, class_validator_1.IsIn)(account_type_1.accountTypes, { message: "Please pick a valid role type from the options." }),
37
+ (0, swagger_1.ApiProperty)({ description: "Role for the invitee" }),
33
38
  __metadata("design:type", String)
34
39
  ], InviteRequestDTO.prototype, "role", void 0);
35
40
  __decorate([
36
- (0, class_validator_1.IsUUID)(4, { message: "Please enter a valid merchant identifier" }),
41
+ (0, class_validator_1.IsUUID)(4, { message: "The merchant identifier doesn't seem right. Could you check it?" }),
42
+ (0, swagger_1.ApiProperty)({ description: "Biller id for the merchant sending the invite" }),
37
43
  __metadata("design:type", String)
38
44
  ], InviteRequestDTO.prototype, "billerId", void 0);
39
45
  __decorate([
40
- (0, class_validator_1.IsUUID)(4, { message: "Please enter a valid user identifier" }),
46
+ (0, class_validator_1.IsUUID)(4, { message: "The user identifier doesn't seem right. Could you check it?" }),
47
+ (0, swagger_1.ApiProperty)({ description: "User id of the inviter" }),
41
48
  __metadata("design:type", String)
42
49
  ], InviteRequestDTO.prototype, "userId", void 0);
43
50
  class AcceptInviteInviteDTO {
44
51
  }
45
52
  exports.AcceptInviteInviteDTO = AcceptInviteInviteDTO;
46
53
  __decorate([
47
- (0, class_validator_1.IsString)({ message: "Please enter the valid invite token" }),
54
+ (0, class_validator_1.IsString)({ message: "Your invite token doesn't seem valid. Could you try again?" }),
55
+ (0, swagger_1.ApiProperty)({ description: "Token provided by user" }),
48
56
  __metadata("design:type", String)
49
57
  ], AcceptInviteInviteDTO.prototype, "token", void 0);
50
58
  __decorate([
51
- (0, class_validator_1.IsString)({ message: "Please enter a valid password" }),
59
+ (0, class_validator_1.IsString)({ message: "Looks like your password isn't valid. Please provide one." }),
60
+ (0, swagger_1.ApiProperty)({ description: "Users password" }),
52
61
  __metadata("design:type", String)
53
62
  ], AcceptInviteInviteDTO.prototype, "password", void 0);
54
63
  class RevokeInviteDTO {
55
64
  }
56
65
  exports.RevokeInviteDTO = RevokeInviteDTO;
57
66
  __decorate([
58
- (0, class_validator_1.IsUUID)(4, { message: "Please select a valid invite" }),
67
+ (0, class_validator_1.IsUUID)(4, { message: "Please select a valid invite to revoke." }),
68
+ (0, swagger_1.ApiProperty)({ description: "Id of the invite" }),
59
69
  __metadata("design:type", String)
60
70
  ], RevokeInviteDTO.prototype, "id", void 0);
@@ -1,2 +1,3 @@
1
1
  export declare const accountTypes: string[];
2
+ export declare const inviteAccountTypes: string[];
2
3
  export declare const InviteStatuses: string[];
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InviteStatuses = exports.accountTypes = void 0;
3
+ exports.InviteStatuses = exports.inviteAccountTypes = exports.accountTypes = void 0;
4
4
  exports.accountTypes = ["ADMINISTRATOR", "USER", "SUPPORT", "BILLER", "BILLER_ADMINISTRATOR", "BILLER_USER"];
5
+ exports.inviteAccountTypes = ["BILLER_ADMINISTRATOR", "BILLER_USER"];
5
6
  exports.InviteStatuses = ["ACCEPTED", "PENDING", "REVOKED"];
@@ -3,10 +3,9 @@ export declare class CreateUserDTO {
3
3
  lastName: string;
4
4
  emailAddress: string;
5
5
  phoneNumber: string;
6
- businessName: string;
7
6
  avatarUrl?: string;
8
7
  corporate?: boolean;
9
- accountType: string;
8
+ role: string;
10
9
  }
11
10
  export declare class UpdateUserDTO extends CreateUserDTO {
12
11
  id: string;
package/dist/user/user.js CHANGED
@@ -11,45 +11,51 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.UpdateUserDTO = exports.CreateUserDTO = void 0;
13
13
  const class_validator_1 = require("class-validator");
14
+ const account_type_1 = require("../types/account.type");
15
+ const swagger_1 = require("@nestjs/swagger");
14
16
  class CreateUserDTO {
15
17
  }
16
18
  exports.CreateUserDTO = CreateUserDTO;
17
19
  __decorate([
18
- (0, class_validator_1.IsString)({ message: "Please enter your first name." }),
20
+ (0, class_validator_1.IsString)({ message: "First name is required. Please provide it." }),
21
+ (0, swagger_1.ApiProperty)({ description: "User's first name" }),
19
22
  __metadata("design:type", String)
20
23
  ], CreateUserDTO.prototype, "firstName", void 0);
21
24
  __decorate([
22
- (0, class_validator_1.IsString)({ message: "Please enter your last name." }),
25
+ (0, class_validator_1.IsString)({ message: "Last name is required. Please provide it." }),
26
+ (0, swagger_1.ApiProperty)({ description: "User's last name" }),
23
27
  __metadata("design:type", String)
24
28
  ], CreateUserDTO.prototype, "lastName", void 0);
25
29
  __decorate([
26
- (0, class_validator_1.IsEmail)(undefined, { message: "Please enter a valid email address" }),
27
- (0, class_validator_1.IsString)({ message: "Please enter a valid email address." }),
30
+ (0, class_validator_1.IsEmail)(undefined, { message: "Looks like your email isn't valid. Please double-check it." }),
31
+ (0, class_validator_1.IsString)({ message: "An email address is required. Please enter one." }),
32
+ (0, swagger_1.ApiProperty)({ description: "User's email address" }),
28
33
  __metadata("design:type", String)
29
34
  ], CreateUserDTO.prototype, "emailAddress", void 0);
30
35
  __decorate([
31
- (0, class_validator_1.IsString)({ message: "Please enter your phone number." }),
36
+ (0, class_validator_1.IsString)({ message: "Phone number is required. Please enter it." }),
37
+ (0, swagger_1.ApiProperty)({ description: "User's phone number" }),
32
38
  __metadata("design:type", String)
33
39
  ], CreateUserDTO.prototype, "phoneNumber", void 0);
34
- __decorate([
35
- (0, class_validator_1.IsString)({ message: "Please enter your business name." }),
36
- __metadata("design:type", String)
37
- ], CreateUserDTO.prototype, "businessName", void 0);
38
40
  __decorate([
39
41
  (0, class_validator_1.IsOptional)() // Allows the property to be optional
40
42
  ,
41
- (0, class_validator_1.IsString)({ message: "Please provide a valid avatar URL." }),
43
+ (0, class_validator_1.IsString)({ message: "Please provide a valid link for the avatar (optional)." }),
44
+ (0, swagger_1.ApiProperty)({ description: "User's profile link" }),
42
45
  __metadata("design:type", String)
43
46
  ], CreateUserDTO.prototype, "avatarUrl", void 0);
44
47
  __decorate([
45
48
  (0, class_validator_1.IsOptional)(),
46
- (0, class_validator_1.IsBoolean)({ message: "Corporate must be a boolean value." }),
49
+ (0, class_validator_1.IsBoolean)({ message: "Corporate should be true or false (optional)." }),
50
+ (0, swagger_1.ApiProperty)({ description: "Corporate or private user" }),
47
51
  __metadata("design:type", Boolean)
48
52
  ], CreateUserDTO.prototype, "corporate", void 0);
49
53
  __decorate([
50
- (0, class_validator_1.IsString)({ message: "Please specify the account type." }),
54
+ (0, class_validator_1.IsString)({ message: "Account type is required. Please specify it." }),
55
+ (0, class_validator_1.IsIn)(account_type_1.accountTypes, { message: "Please select a valid account type" }),
56
+ (0, swagger_1.ApiProperty)({ description: "users role" }),
51
57
  __metadata("design:type", String)
52
- ], CreateUserDTO.prototype, "accountType", void 0);
58
+ ], CreateUserDTO.prototype, "role", void 0);
53
59
  class UpdateUserDTO extends CreateUserDTO {
54
60
  }
55
61
  exports.UpdateUserDTO = UpdateUserDTO;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resurgence-data",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
4
4
  "description": "DTOs and shareable resources",
5
5
  "module": "dist/index.js",
6
6
  "main": "dist/index.js",
@@ -24,6 +24,7 @@
24
24
  "typescript": "^5.7.2"
25
25
  },
26
26
  "dependencies": {
27
+ "@nestjs/swagger": "^8.1.1",
27
28
  "@types/jest": "^29.5.14",
28
29
  "class-transformer": "^0.5.1",
29
30
  "class-validator": "^0.14.1",
@@ -1,6 +1,7 @@
1
1
  import { IsBoolean, IsEmail, IsIn, IsOptional, IsString, IsUUID, Length } from "class-validator";
2
- import { accountTypes } from "../types/account.type";
2
+ import { accountTypes, inviteAccountTypes } from "../types/account.type";
3
3
  import { isSameAs } from "../validation/custom-validation";
4
+ import { ApiProperty } from "@nestjs/swagger";
4
5
 
5
6
  export class SignUpDTO {
6
7
  firstName: string;
@@ -11,35 +12,35 @@ export class SignUpDTO {
11
12
 
12
13
  export class LoginRequestDTO {
13
14
  @IsString({ message: "Please enter your username / email address" })
15
+ @ApiProperty({ description: "The email address for the user" })
14
16
  emailAddress: string;
15
17
  @IsString({ message: "Please enter your password" })
18
+ @ApiProperty({ description: "The password for the user" })
16
19
  password: string;
17
20
  }
18
21
 
19
22
  export class RecoverAccountDTO {
20
23
  @IsString({ message: "Please enter your email address." })
24
+ @ApiProperty({ description: "The email address for the user" })
21
25
  emailAddress: string;
22
26
  }
23
-
24
- export class SendInviteDTO {
25
- @IsUUID(4, { message: "Please provide a valid merchant / biller identifier" })
26
- billerId: string;
27
- @IsString({ message: "Please enter the email address of your invitee" })
28
- @IsEmail(undefined, { message: "Please enter a valid email address" })
27
+ export class MFARequestDTO {
28
+ @IsString({ message: "Please enter your email address." })
29
+ @ApiProperty({ description: "The email address for the user" })
29
30
  emailAddress: string;
30
- @IsString({ message: "Please enter a valid data type" })
31
- @IsIn(accountTypes, { message: "Please select a valid role type" })
32
- role: string;
33
31
  }
34
32
 
35
33
  export class ActivationRequestDTO {
36
34
  @IsString({ message: "Please provide your activation code" })
35
+ @ApiProperty({ description: "Token provided in the users email" })
37
36
  token: string;
38
37
  @IsString({ message: "Please provide your password" })
38
+ @ApiProperty({ description: "The password for the user" })
39
39
  password: string;
40
40
  @IsOptional()
41
41
  @IsString({ message: "Please confirm your password" })
42
42
  @isSameAs("password", { message: "Your passwords to not match. Please check" })
43
+ @ApiProperty({ description: "Confirmed password from user" })
43
44
  passwordConfirm?: string;
44
45
  }
45
46
 
@@ -58,9 +59,11 @@ export class UpdateAuthenticationDTO {
58
59
  export class TwoFactorAuthRequestDTO {
59
60
  @IsEmail(undefined, { message: "Please enter a valid email address" })
60
61
  @IsString({ message: "Please enter the email address of your invitee" })
62
+ @ApiProperty({ description: "Email address of the user" })
61
63
  emailAddress: string;
62
64
  @IsString({ message: "Please provide the 6 character code" })
63
65
  @Length(6, 6, { message: "Please enter a 6 character code" })
66
+ @ApiProperty({ description: "6 digit code provided by the user" })
64
67
  token: string;
65
68
  }
66
69
 
@@ -1,30 +1,46 @@
1
1
  import { IsEmail, IsIn, IsString, IsUUID } from "class-validator";
2
2
  import { accountTypes } from "../types/account.type";
3
+ import { ApiProperty } from "@nestjs/swagger";
3
4
 
4
5
  export class InviteRequestDTO {
5
- @IsString({ message: "Please enter your invitees first name" })
6
+ @IsString({ message: "Could you provide your invitee's first name?" })
7
+ @ApiProperty({ description: "First name of the invitee" })
6
8
  firstName: string;
7
- @IsString({ message: "Please enter your invitees first name" })
9
+
10
+ @IsString({ message: "Could you provide your invitee's last name?" })
11
+ @ApiProperty({ description: "Last name of the invitee" })
8
12
  lastName: string;
9
- @IsEmail(undefined, { message: "Please enter a valid email address" })
10
- @IsString({ message: "Please enter your invitees first name" })
13
+
14
+ @IsEmail(undefined, { message: "Hmm, that doesn't look like a valid email. Could you double-check it?" })
15
+ @IsString({ message: "We need your invitee's email address. Please provide it." })
16
+ @ApiProperty({ description: "Email address of the invitee" })
11
17
  emailAddress: string;
12
- @IsIn(accountTypes, { message: "Please select a valid role tyoe" })
18
+
19
+ @IsIn(accountTypes, { message: "Please pick a valid role type from the options." })
20
+ @ApiProperty({ description: "Role for the invitee" })
13
21
  role: string;
14
- @IsUUID(4, { message: "Please enter a valid merchant identifier" })
22
+
23
+ @IsUUID(4, { message: "The merchant identifier doesn't seem right. Could you check it?" })
24
+ @ApiProperty({ description: "Biller id for the merchant sending the invite" })
15
25
  billerId: string;
16
- @IsUUID(4, { message: "Please enter a valid user identifier" })
26
+
27
+ @IsUUID(4, { message: "The user identifier doesn't seem right. Could you check it?" })
28
+ @ApiProperty({ description: "User id of the inviter" })
17
29
  userId: string;
18
30
  }
19
31
 
20
32
  export class AcceptInviteInviteDTO {
21
- @IsString({ message: "Please enter the valid invite token" })
33
+ @IsString({ message: "Your invite token doesn't seem valid. Could you try again?" })
34
+ @ApiProperty({ description: "Token provided by user" })
22
35
  token: string;
23
- @IsString({ message: "Please enter a valid password" })
36
+
37
+ @IsString({ message: "Looks like your password isn't valid. Please provide one." })
38
+ @ApiProperty({ description: "Users password" })
24
39
  password: string;
25
40
  }
26
41
 
27
42
  export class RevokeInviteDTO {
28
- @IsUUID(4, { message: "Please select a valid invite" })
43
+ @IsUUID(4, { message: "Please select a valid invite to revoke." })
44
+ @ApiProperty({ description: "Id of the invite" })
29
45
  id: string;
30
46
  }
@@ -1,3 +1,4 @@
1
1
  export const accountTypes = ["ADMINISTRATOR", "USER", "SUPPORT", "BILLER", "BILLER_ADMINISTRATOR", "BILLER_USER"];
2
+ export const inviteAccountTypes = ["BILLER_ADMINISTRATOR", "BILLER_USER"];
2
3
 
3
4
  export const InviteStatuses = ["ACCEPTED", "PENDING", "REVOKED"];
package/src/user/user.ts CHANGED
@@ -1,29 +1,39 @@
1
- import { IsBoolean, IsEmail, IsOptional, IsString, IsUUID } from "class-validator";
1
+ import { IsBoolean, IsEmail, IsIn, IsOptional, IsString, IsUUID } from "class-validator";
2
+ import { accountTypes } from "../types/account.type";
3
+ import { ApiProperty } from "@nestjs/swagger";
2
4
 
3
5
  export class CreateUserDTO {
4
- @IsString({ message: "Please enter your first name." })
6
+ @IsString({ message: "First name is required. Please provide it." })
7
+ @ApiProperty({ description: "User's first name" })
5
8
  firstName: string;
6
9
 
7
- @IsString({ message: "Please enter your last name." })
10
+ @IsString({ message: "Last name is required. Please provide it." })
11
+ @ApiProperty({ description: "User's last name" })
8
12
  lastName: string;
9
13
 
10
- @IsEmail(undefined, { message: "Please enter a valid email address" })
11
- @IsString({ message: "Please enter a valid email address." })
14
+ @IsEmail(undefined, { message: "Looks like your email isn't valid. Please double-check it." })
15
+ @IsString({ message: "An email address is required. Please enter one." })
16
+ @ApiProperty({ description: "User's email address" })
12
17
  emailAddress: string;
13
18
 
14
- @IsString({ message: "Please enter your phone number." })
19
+ @IsString({ message: "Phone number is required. Please enter it." })
20
+ @ApiProperty({ description: "User's phone number" })
15
21
  phoneNumber: string;
16
- @IsString({ message: "Please enter your business name." })
17
- businessName: string;
22
+
18
23
  @IsOptional() // Allows the property to be optional
19
- @IsString({ message: "Please provide a valid avatar URL." })
24
+ @IsString({ message: "Please provide a valid link for the avatar (optional)." })
25
+ @ApiProperty({ description: "User's profile link" })
20
26
  avatarUrl?: string;
27
+
21
28
  @IsOptional()
22
- @IsBoolean({ message: "Corporate must be a boolean value." })
29
+ @IsBoolean({ message: "Corporate should be true or false (optional)." })
30
+ @ApiProperty({ description: "Corporate or private user" })
23
31
  corporate?: boolean;
24
32
 
25
- @IsString({ message: "Please specify the account type." })
26
- accountType: string;
33
+ @IsString({ message: "Account type is required. Please specify it." })
34
+ @IsIn(accountTypes, { message: "Please select a valid account type" })
35
+ @ApiProperty({ description: "users role" })
36
+ role: string;
27
37
  }
28
38
 
29
39
  export class UpdateUserDTO extends CreateUserDTO {