@fiado/type-kit 1.0.4 → 1.0.5
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/bin/account/dtos/AccountResponse.d.ts +21 -0
- package/bin/account/dtos/AccountResponse.js +85 -0
- package/bin/account/dtos/CreateAccountRequest.d.ts +14 -0
- package/bin/account/dtos/CreateAccountRequest.js +65 -0
- package/bin/account/dtos/CreatePockeRequest.d.ts +4 -0
- package/bin/account/dtos/CreatePockeRequest.js +31 -0
- package/bin/account/dtos/PocketResponse.d.ts +0 -0
- package/bin/account/dtos/PocketResponse.js +0 -0
- package/bin/account/enums/AccountStatus.d.ts +5 -0
- package/bin/account/enums/AccountStatus.js +9 -0
- package/bin/address/dtos/AddressBase.d.ts +34 -0
- package/bin/address/dtos/AddressBase.js +163 -0
- package/bin/address/dtos/AddressResponse.d.ts +7 -0
- package/bin/address/dtos/AddressResponse.js +47 -0
- package/bin/address/dtos/CreateAddressRequest.d.ts +3 -0
- package/bin/address/dtos/CreateAddressRequest.js +7 -0
- package/bin/address/dtos/Geometry.d.ts +3 -0
- package/bin/address/dtos/Geometry.js +2 -0
- package/bin/address/dtos/Place.d.ts +21 -0
- package/bin/address/dtos/Place.js +112 -0
- package/bin/address/dtos/Shipping.d.ts +11 -0
- package/bin/address/dtos/Shipping.js +57 -0
- package/bin/address/dtos/Timezone.d.ts +4 -0
- package/bin/address/dtos/Timezone.js +2 -0
- package/bin/address/enums/AddressProvider.d.ts +9 -0
- package/bin/address/enums/AddressProvider.js +13 -0
- package/bin/address/enums/AddressStatus.d.ts +9 -0
- package/bin/address/enums/AddressStatus.js +13 -0
- package/bin/address/index.d.ts +1 -1
- package/bin/address/index.js +1 -1
- package/bin/card/dtos/CardActivateRequest.d.ts +4 -0
- package/bin/card/dtos/CardActivateRequest.js +26 -0
- package/bin/card/dtos/CardApplicationRequest.d.ts +6 -0
- package/bin/card/dtos/CardApplicationRequest.js +34 -0
- package/bin/card/dtos/CardUpdateRequest.d.ts +5 -0
- package/bin/card/dtos/CardUpdateRequest.js +28 -0
- package/bin/card/dtos/CreateCardRequest.d.ts +34 -0
- package/bin/card/dtos/CreateCardRequest.js +176 -0
- package/bin/card/validations/CardUpdateKeyConstraint.js +1 -2
- package/bin/card/validations/IsPhoneNumberConstraint.d.ts +6 -0
- package/bin/card/validations/IsPhoneNumberConstraint.js +36 -0
- package/bin/country/enums/Country.d.ts +4 -0
- package/bin/country/enums/Country.js +8 -0
- package/bin/country/enums/CountryId.js +1 -0
- package/bin/directory/enums/TypeOfDirectoryId.d.ts +5 -0
- package/bin/directory/enums/TypeOfDirectoryId.js +9 -0
- package/bin/helpers/constans/regex.d.ts +1 -0
- package/bin/helpers/constans/regex.js +3 -1
- package/bin/index.d.ts +4 -4
- package/bin/index.js +4 -4
- package/package.json +1 -1
- package/src/account/dtos/AccountResponse.ts +60 -0
- package/src/account/dtos/CreateAccountRequest.ts +45 -0
- package/src/account/dtos/CreatePockeRequest.ts +19 -0
- package/src/account/dtos/PocketResponse.ts +0 -0
- package/src/account/enums/AccountStatus.ts +7 -0
- package/src/address/dtos/AddressBase.ts +131 -0
- package/src/address/dtos/AddressResponse.ts +41 -0
- package/src/address/dtos/CreateAddressRequest.ts +7 -0
- package/src/address/dtos/Geometry.ts +5 -0
- package/src/address/dtos/Place.ts +84 -0
- package/src/address/dtos/{AddressShippingDto.ts → Shipping.ts} +1 -1
- package/src/address/dtos/Timezone.ts +6 -0
- package/src/address/enums/AddressProvider.ts +10 -0
- package/src/address/enums/AddressStatus.ts +10 -0
- package/src/address/index.ts +1 -1
- package/src/card/dtos/{CardActivateRequestDto.ts → CardActivateRequest.ts} +1 -1
- package/src/card/dtos/{CardApplicationRequestDto.ts → CardApplicationRequest.ts} +4 -4
- package/src/card/dtos/{CardUpdateRequestDto.ts → CardUpdateRequest.ts} +1 -1
- package/src/card/dtos/{CreateCardRequestDto.ts → CreateCardRequest.ts} +4 -4
- package/src/card/validations/CardUpdateKeyConstraint.ts +3 -5
- package/src/card/validations/IsPhoneNumberConstraint.ts +26 -0
- package/src/country/enums/Country.ts +6 -0
- package/src/country/enums/CountryId.ts +3 -0
- package/src/directory/enums/TypeOfDirectoryId.ts +7 -0
- package/src/helpers/constans/regex.ts +2 -0
- package/src/index.ts +4 -4
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import { IsEnum, IsNumber, IsOptional, IsString, IsDateString } from 'class-validator';
|
|
4
|
+
import { Provider } from '../../provider/enums/Provider';
|
|
5
|
+
import { Country } from '../../country/enums/Country';
|
|
6
|
+
import { AccountStatus } from '../enums/AccountStatus';
|
|
7
|
+
import { TypeOfDirectoryId } from '../../directory/enums/TypeOfDirectoryId';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export class AccountResponse {
|
|
11
|
+
@IsString()
|
|
12
|
+
id: string;
|
|
13
|
+
|
|
14
|
+
@IsOptional()
|
|
15
|
+
@IsString()
|
|
16
|
+
typeOfAccountId: string;
|
|
17
|
+
|
|
18
|
+
@IsOptional()
|
|
19
|
+
@IsString()
|
|
20
|
+
externalAccountId: string;
|
|
21
|
+
|
|
22
|
+
@IsOptional()
|
|
23
|
+
@IsString()
|
|
24
|
+
externalSubAccountId: string | null;
|
|
25
|
+
|
|
26
|
+
@IsEnum(Provider)
|
|
27
|
+
provider: Provider;
|
|
28
|
+
|
|
29
|
+
@IsString()
|
|
30
|
+
directoryId: string;
|
|
31
|
+
|
|
32
|
+
@IsEnum(TypeOfDirectoryId)
|
|
33
|
+
typeOfDirectoryId: TypeOfDirectoryId;
|
|
34
|
+
|
|
35
|
+
@IsNumber()
|
|
36
|
+
currentBalance: number;
|
|
37
|
+
|
|
38
|
+
@IsNumber()
|
|
39
|
+
balanceLock: number;
|
|
40
|
+
|
|
41
|
+
@IsEnum(Country)
|
|
42
|
+
countryId: Country;
|
|
43
|
+
|
|
44
|
+
@IsDateString()
|
|
45
|
+
createDate: string;
|
|
46
|
+
|
|
47
|
+
@IsDateString()
|
|
48
|
+
lastUpdateDate: string;
|
|
49
|
+
|
|
50
|
+
@IsOptional()
|
|
51
|
+
@IsString()
|
|
52
|
+
accountNumber: string
|
|
53
|
+
|
|
54
|
+
@IsOptional()
|
|
55
|
+
@IsString()
|
|
56
|
+
routingNumber: string;
|
|
57
|
+
|
|
58
|
+
@IsEnum(AccountStatus)
|
|
59
|
+
status: AccountStatus;
|
|
60
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { IsEmail, IsEnum, IsString, ValidateNested, IsDateString, Matches, Length } from 'class-validator';
|
|
2
|
+
import { AddressResponse } from "../../address/dtos/AddressResponse";
|
|
3
|
+
import { Country } from "../../country/enums/Country";
|
|
4
|
+
import { regexUuidV4 } from '../../helpers/constans/regex';
|
|
5
|
+
import { TypeOfDirectoryId } from '../../directory/enums/TypeOfDirectoryId';
|
|
6
|
+
import { IsPhoneNumberFiado } from '../../card/validations/IsPhoneNumberConstraint';
|
|
7
|
+
|
|
8
|
+
export class CreateAccountRequest {
|
|
9
|
+
|
|
10
|
+
@IsString()
|
|
11
|
+
@Matches(regexUuidV4,
|
|
12
|
+
{
|
|
13
|
+
message: 'directoryId must be a valid UUID v4',
|
|
14
|
+
})
|
|
15
|
+
directoryId: string;
|
|
16
|
+
|
|
17
|
+
@IsEnum(TypeOfDirectoryId)
|
|
18
|
+
typeOfDirectoryId: string;
|
|
19
|
+
|
|
20
|
+
@IsString()
|
|
21
|
+
firstName: string;
|
|
22
|
+
|
|
23
|
+
@IsString()
|
|
24
|
+
|
|
25
|
+
lastName: string;
|
|
26
|
+
|
|
27
|
+
@IsPhoneNumberFiado()
|
|
28
|
+
phoneNumber: string;
|
|
29
|
+
|
|
30
|
+
@ValidateNested()
|
|
31
|
+
address: AddressResponse;
|
|
32
|
+
|
|
33
|
+
@IsEmail()
|
|
34
|
+
email: string;
|
|
35
|
+
|
|
36
|
+
@IsDateString()
|
|
37
|
+
dob: string;
|
|
38
|
+
|
|
39
|
+
@IsString()
|
|
40
|
+
@Length(1, 30)
|
|
41
|
+
documentNumber: string;
|
|
42
|
+
|
|
43
|
+
@IsEnum(Country)
|
|
44
|
+
countryId: Country;
|
|
45
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IsString, Matches } from "class-validator";
|
|
2
|
+
import { regexUuidV4 } from "../../helpers/constans/regex";
|
|
3
|
+
|
|
4
|
+
export class CreatePocketRequest {
|
|
5
|
+
|
|
6
|
+
@IsString()
|
|
7
|
+
@Matches(regexUuidV4,
|
|
8
|
+
{
|
|
9
|
+
message: 'beneficiaryDirectoryId must be a valid UUID v4',
|
|
10
|
+
})
|
|
11
|
+
beneficiaryDirectoryId?: string;
|
|
12
|
+
|
|
13
|
+
@IsString()
|
|
14
|
+
@Matches(regexUuidV4,
|
|
15
|
+
{
|
|
16
|
+
message: 'accountId must be a valid UUID v4',
|
|
17
|
+
})
|
|
18
|
+
accountId: string;
|
|
19
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { IsBoolean, IsEnum, IsNumber, IsOptional, IsString, Length, Matches, ValidateNested } from 'class-validator';
|
|
5
|
+
import { TypeOfDirectoryId } from "../../directory/enums/TypeOfDirectoryId";
|
|
6
|
+
import { AddressProvider } from "../enums/AddressProvider";
|
|
7
|
+
import { AddressStatus } from "../enums/AddressStatus";
|
|
8
|
+
import { Place } from "./Place";
|
|
9
|
+
import { CountryId } from '../../country/enums/CountryId';
|
|
10
|
+
import { regexIso8601, regexUuidV4 } from '../../helpers/constans/regex';
|
|
11
|
+
|
|
12
|
+
export class AddressBase {
|
|
13
|
+
|
|
14
|
+
@IsOptional()
|
|
15
|
+
@IsString()
|
|
16
|
+
@Matches(regexUuidV4,
|
|
17
|
+
{
|
|
18
|
+
message: 'id must be a valid UUID v4',
|
|
19
|
+
})
|
|
20
|
+
id?: string;
|
|
21
|
+
|
|
22
|
+
@IsNumber()
|
|
23
|
+
@IsOptional()
|
|
24
|
+
distance?: number;
|
|
25
|
+
|
|
26
|
+
@IsEnum(TypeOfDirectoryId)
|
|
27
|
+
createdBy: TypeOfDirectoryId;
|
|
28
|
+
|
|
29
|
+
@IsString()
|
|
30
|
+
@Matches(regexUuidV4,
|
|
31
|
+
{
|
|
32
|
+
message: 'directoryId must be a valid UUID v4',
|
|
33
|
+
})
|
|
34
|
+
directoryId: string;
|
|
35
|
+
|
|
36
|
+
@IsBoolean()
|
|
37
|
+
isPrincipal: boolean;
|
|
38
|
+
|
|
39
|
+
@IsOptional()
|
|
40
|
+
@IsString()
|
|
41
|
+
@Length(1, 100)
|
|
42
|
+
tag?: string;
|
|
43
|
+
|
|
44
|
+
@IsString()
|
|
45
|
+
@Length(1, 100)
|
|
46
|
+
tenantId: string;
|
|
47
|
+
|
|
48
|
+
@IsString()
|
|
49
|
+
typeOfAddressId: string;
|
|
50
|
+
|
|
51
|
+
@IsEnum(TypeOfDirectoryId)
|
|
52
|
+
typeOfDirectoryId: TypeOfDirectoryId;
|
|
53
|
+
|
|
54
|
+
@IsEnum(AddressProvider)
|
|
55
|
+
provider: AddressProvider;
|
|
56
|
+
|
|
57
|
+
@ValidateNested()
|
|
58
|
+
place: Place;
|
|
59
|
+
|
|
60
|
+
@IsString()
|
|
61
|
+
@Matches(regexIso8601,
|
|
62
|
+
{
|
|
63
|
+
message: 'validFrom must be a valid ISO 8601 date string',
|
|
64
|
+
})
|
|
65
|
+
validFrom: string;
|
|
66
|
+
|
|
67
|
+
@IsOptional()
|
|
68
|
+
@IsString()
|
|
69
|
+
@Matches(regexIso8601,
|
|
70
|
+
{
|
|
71
|
+
message: 'validUntil must be a valid ISO 8601 date string',
|
|
72
|
+
})
|
|
73
|
+
validUntil?: string;
|
|
74
|
+
|
|
75
|
+
@IsEnum(AddressStatus)
|
|
76
|
+
addressStatus: AddressStatus;
|
|
77
|
+
|
|
78
|
+
@IsOptional()
|
|
79
|
+
@IsString()
|
|
80
|
+
@Length(1, 200)
|
|
81
|
+
additionalInformation?: string;
|
|
82
|
+
|
|
83
|
+
@IsBoolean()
|
|
84
|
+
helpNeeded: boolean;
|
|
85
|
+
|
|
86
|
+
@IsOptional()
|
|
87
|
+
@IsString()
|
|
88
|
+
@Length(1, 10)
|
|
89
|
+
internalNumber?: string;
|
|
90
|
+
|
|
91
|
+
@IsEnum(CountryId)
|
|
92
|
+
countryId: CountryId;
|
|
93
|
+
|
|
94
|
+
@IsString()
|
|
95
|
+
@Length(1, 100)
|
|
96
|
+
street?: string;
|
|
97
|
+
|
|
98
|
+
@IsString()
|
|
99
|
+
@Length(1, 10)
|
|
100
|
+
addressNumber?: string;
|
|
101
|
+
|
|
102
|
+
@IsOptional()
|
|
103
|
+
@IsString()
|
|
104
|
+
@Length(2, 60)
|
|
105
|
+
municipality?: string;
|
|
106
|
+
|
|
107
|
+
@IsOptional()
|
|
108
|
+
@IsString()
|
|
109
|
+
subMunicipality?: string;
|
|
110
|
+
|
|
111
|
+
@IsOptional()
|
|
112
|
+
@IsString()
|
|
113
|
+
@Length(2, 60)
|
|
114
|
+
neighborhood?: string;
|
|
115
|
+
|
|
116
|
+
@IsOptional()
|
|
117
|
+
@IsString()
|
|
118
|
+
@Length(2, 60)
|
|
119
|
+
subRegion?: string;
|
|
120
|
+
|
|
121
|
+
@IsString()
|
|
122
|
+
@Length(5, 10)
|
|
123
|
+
region?: string;
|
|
124
|
+
|
|
125
|
+
@IsString()
|
|
126
|
+
@Length(5, 10)
|
|
127
|
+
postalCode?: string;
|
|
128
|
+
|
|
129
|
+
@IsEnum(CountryId)
|
|
130
|
+
country: string;
|
|
131
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { IsOptional, IsString, Length, Matches } from 'class-validator';
|
|
5
|
+
|
|
6
|
+
import { regexIso8601, regexUuidV4 } from '../../helpers/constans/regex';
|
|
7
|
+
import { AddressBase } from './AddressBase';
|
|
8
|
+
|
|
9
|
+
export class AddressResponse extends AddressBase {
|
|
10
|
+
|
|
11
|
+
@IsString()
|
|
12
|
+
@Matches(regexUuidV4,
|
|
13
|
+
{
|
|
14
|
+
message: 'id must be a valid UUID v4',
|
|
15
|
+
})
|
|
16
|
+
id: string
|
|
17
|
+
|
|
18
|
+
@IsOptional()
|
|
19
|
+
@IsString()
|
|
20
|
+
@Matches(regexIso8601,
|
|
21
|
+
{
|
|
22
|
+
message: 'createDate must be a valid ISO 8601 date string',
|
|
23
|
+
})
|
|
24
|
+
createDate: string;
|
|
25
|
+
|
|
26
|
+
@IsOptional()
|
|
27
|
+
@IsString()
|
|
28
|
+
@Matches(regexIso8601,
|
|
29
|
+
{
|
|
30
|
+
message: 'updateDate must be a valid ISO 8601 date string',
|
|
31
|
+
})
|
|
32
|
+
updateDate?: string;
|
|
33
|
+
|
|
34
|
+
@IsOptional()
|
|
35
|
+
@IsString()
|
|
36
|
+
@Length(1, 100)
|
|
37
|
+
updatedBy?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { IsArray, IsBoolean, IsEnum, IsOptional, IsString, Length, ValidateNested } from 'class-validator';
|
|
2
|
+
import { Geometry } from "./Geometry";
|
|
3
|
+
import { Timezone } from "./Timezone";
|
|
4
|
+
import { Country } from '../../country/enums/Country';
|
|
5
|
+
|
|
6
|
+
export class Place {
|
|
7
|
+
@ValidateNested()
|
|
8
|
+
geometry: Geometry;
|
|
9
|
+
|
|
10
|
+
@IsOptional()
|
|
11
|
+
@IsString()
|
|
12
|
+
addressNumber?: string;
|
|
13
|
+
|
|
14
|
+
@IsOptional()
|
|
15
|
+
@IsArray()
|
|
16
|
+
@IsString({ each: true })
|
|
17
|
+
categories?: string[];
|
|
18
|
+
|
|
19
|
+
@IsOptional()
|
|
20
|
+
@IsEnum(Country)
|
|
21
|
+
country?: string;
|
|
22
|
+
|
|
23
|
+
@IsBoolean()
|
|
24
|
+
interpolated: boolean;
|
|
25
|
+
|
|
26
|
+
@IsOptional()
|
|
27
|
+
@IsString()
|
|
28
|
+
@Length(1, 300)
|
|
29
|
+
label?: string;
|
|
30
|
+
|
|
31
|
+
@IsOptional()
|
|
32
|
+
@IsString()
|
|
33
|
+
@Length(1, 60)
|
|
34
|
+
municipality?: string;
|
|
35
|
+
|
|
36
|
+
@IsOptional()
|
|
37
|
+
@IsString()
|
|
38
|
+
@Length(2, 60)
|
|
39
|
+
neighborhood?: string;
|
|
40
|
+
|
|
41
|
+
@IsOptional()
|
|
42
|
+
@IsString()
|
|
43
|
+
@Length(5, 10)
|
|
44
|
+
postalCode?: string;
|
|
45
|
+
|
|
46
|
+
@IsOptional()
|
|
47
|
+
@IsString()
|
|
48
|
+
@Length(5, 10)
|
|
49
|
+
region?: string;
|
|
50
|
+
|
|
51
|
+
@IsOptional()
|
|
52
|
+
@IsString()
|
|
53
|
+
@Length(1, 100)
|
|
54
|
+
street?: string;
|
|
55
|
+
|
|
56
|
+
@IsOptional()
|
|
57
|
+
@IsString()
|
|
58
|
+
@Length(2, 60)
|
|
59
|
+
subMunicipality?: string;
|
|
60
|
+
|
|
61
|
+
@IsOptional()
|
|
62
|
+
@IsString()
|
|
63
|
+
@Length(2, 60)
|
|
64
|
+
subRegion?: string;
|
|
65
|
+
|
|
66
|
+
@IsOptional()
|
|
67
|
+
@IsArray()
|
|
68
|
+
@IsString({ each: true })
|
|
69
|
+
supplementalCategories?: string[];
|
|
70
|
+
|
|
71
|
+
@IsOptional()
|
|
72
|
+
@ValidateNested()
|
|
73
|
+
timezone?: Timezone;
|
|
74
|
+
|
|
75
|
+
@IsOptional()
|
|
76
|
+
@IsString()
|
|
77
|
+
@Length(1, 10)
|
|
78
|
+
unitNumber?: string;
|
|
79
|
+
|
|
80
|
+
@IsOptional()
|
|
81
|
+
@IsString()
|
|
82
|
+
@Length(1, 10)
|
|
83
|
+
unitType?: string;
|
|
84
|
+
}
|
package/src/address/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './dtos/
|
|
1
|
+
export * from './dtos/Shipping';
|
|
@@ -4,9 +4,9 @@ import { IsEnum, IsNotEmpty, ValidateNested } from 'class-validator';
|
|
|
4
4
|
import { Type } from 'class-transformer';
|
|
5
5
|
import { CountryId } from '../../country/enums/CountryId';
|
|
6
6
|
import { CardType } from '../enums/CardType';
|
|
7
|
-
import {
|
|
7
|
+
import { Shipping } from '../../address/dtos/Shipping';
|
|
8
8
|
|
|
9
|
-
export class
|
|
9
|
+
export class CardApplicationRequest {
|
|
10
10
|
@IsEnum(CountryId)
|
|
11
11
|
countryId: number;
|
|
12
12
|
|
|
@@ -15,6 +15,6 @@ export class CardApplicationRequestDto {
|
|
|
15
15
|
|
|
16
16
|
@IsNotEmpty()
|
|
17
17
|
@ValidateNested()
|
|
18
|
-
@Type(() =>
|
|
19
|
-
address:
|
|
18
|
+
@Type(() => Shipping)
|
|
19
|
+
address: Shipping;
|
|
20
20
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { IsString, IsOptional, IsEnum, ValidateNested, IsNumber, Min, Max, Length, Matches } from 'class-validator';
|
|
2
2
|
import { Type } from 'class-transformer';
|
|
3
3
|
import { CountryId } from '../../country/enums/CountryId';
|
|
4
|
-
import { ShippingAddressDto } from '../../address/dtos/AddressShippingDto';
|
|
5
4
|
import { CardType } from '../enums/CardType';
|
|
6
5
|
import { Brand } from '../enums/Brand';
|
|
7
6
|
import { OwnershipType } from '../enums/OwnershipType';
|
|
8
7
|
import { Status } from '../enums/Status';
|
|
9
8
|
import { regexIso8601, regexUuidV4 } from '../../helpers/constans/regex';
|
|
9
|
+
import { Shipping } from '../../address';
|
|
10
10
|
|
|
11
|
-
export class
|
|
11
|
+
export class CreateCardRequest {
|
|
12
12
|
|
|
13
13
|
@IsOptional()
|
|
14
14
|
@IsString()
|
|
@@ -136,6 +136,6 @@ export class CreateCardRequestDto {
|
|
|
136
136
|
|
|
137
137
|
@IsOptional()
|
|
138
138
|
@ValidateNested()
|
|
139
|
-
@Type(() =>
|
|
140
|
-
shippedAddress?:
|
|
139
|
+
@Type(() => Shipping)
|
|
140
|
+
shippedAddress?: Shipping;
|
|
141
141
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ValidationArguments, ValidationOptions, ValidatorConstraint, registerDecorator } from "class-validator";
|
|
2
|
-
import {
|
|
2
|
+
import { CardUpdateRequest } from "../dtos/CardUpdateRequest";
|
|
3
3
|
import { Status } from "../enums/Status";
|
|
4
4
|
import { UpdateKey } from "../enums/UpdateKey";
|
|
5
5
|
|
|
@@ -9,7 +9,7 @@ export class CardUpdateKeyConstraint {
|
|
|
9
9
|
|
|
10
10
|
public static validateUpdateKey(value: string | Status, arg: ValidationArguments) {
|
|
11
11
|
|
|
12
|
-
const cardUpdateRequest = arg.object as
|
|
12
|
+
const cardUpdateRequest = arg.object as CardUpdateRequest;
|
|
13
13
|
|
|
14
14
|
// Validar si el valor es uno de los status válidos
|
|
15
15
|
if (cardUpdateRequest.type === UpdateKey.CHANGE_STATUS) {
|
|
@@ -37,10 +37,8 @@ export class CardUpdateKeyConstraint {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
defaultMessage(args: ValidationArguments) {
|
|
40
|
-
|
|
41
|
-
return "El valor no es adecuado para el tipo de actualización.";
|
|
40
|
+
return "The value is not valid for the update type.";
|
|
42
41
|
}
|
|
43
|
-
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
export function IsValueValid(validationOptions?: ValidationOptions) {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ValidatorConstraint, ValidatorConstraintInterface, ValidationArguments, registerDecorator, ValidationOptions } from 'class-validator';
|
|
2
|
+
import { regexPhoneNumber } from '../../helpers/constans/regex';
|
|
3
|
+
|
|
4
|
+
@ValidatorConstraint({ async: true })
|
|
5
|
+
export class IsPhoneNumberConstraint implements ValidatorConstraintInterface {
|
|
6
|
+
validate(phoneNumber: string, args: ValidationArguments) {
|
|
7
|
+
return regexPhoneNumber.test(phoneNumber);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
defaultMessage(args: ValidationArguments) {
|
|
11
|
+
return "The phone number is not valid. The expected format is +############.";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Decorador que usaremos en nuestras clases DTO
|
|
16
|
+
export function IsPhoneNumberFiado(validationOptions?: ValidationOptions) {
|
|
17
|
+
return function (object: Object, propertyName: string) {
|
|
18
|
+
registerDecorator({
|
|
19
|
+
target: object.constructor,
|
|
20
|
+
propertyName: propertyName,
|
|
21
|
+
options: validationOptions,
|
|
22
|
+
constraints: [],
|
|
23
|
+
validator: IsPhoneNumberConstraint,
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
export const regexUuidV4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
5
5
|
// Expresión regular para validar fecha ISO 8601
|
|
6
6
|
export const regexIso8601 = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/;
|
|
7
|
+
// Expresión regular para validar un número de teléfono
|
|
8
|
+
export const regexPhoneNumber = /^\+\d{12}$/;
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from './card/dtos/
|
|
2
|
-
export * from './card/dtos/
|
|
3
|
-
export * from './card/dtos/
|
|
4
|
-
export * from './card/dtos/
|
|
1
|
+
export * from './card/dtos/CardActivateRequest';
|
|
2
|
+
export * from './card/dtos/CardApplicationRequest';
|
|
3
|
+
export * from './card/dtos/CreateCardRequest';
|
|
4
|
+
export * from './card/dtos/CardUpdateRequest';
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|