forked from InsurNiffy/niff-Stellar-shurance
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-claim-transaction.dto.ts
More file actions
66 lines (60 loc) · 1.57 KB
/
Copy pathbuild-claim-transaction.dto.ts
File metadata and controls
66 lines (60 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { ApiProperty } from '@nestjs/swagger';
import {
IsArray,
IsInt,
IsPositive,
IsString,
Matches,
MaxLength,
Validate,
ValidatorConstraint,
ValidatorConstraintInterface,
} from 'class-validator';
@ValidatorConstraint({ name: 'posIntString', async: false })
class PositiveIntStringConstraint implements ValidatorConstraintInterface {
validate(value: string) {
return /^\d+$/.test(value) && BigInt(value) > BigInt(0);
}
defaultMessage() {
return 'amount must be a positive integer string (stroops)';
}
}
export class BuildClaimTransactionDto {
@ApiProperty({
description: 'Stellar public key of the claimant.',
example: 'GDVOEGATQV4FGUJKDEBEYT5NAPWJ55MEMJVLC5TU7Y74WD73PPAS4TYW',
})
@IsString()
@Matches(/^G[A-Z2-7]{55}$/, {
message: 'holder must be a valid Stellar public key (G...)',
})
holder!: string;
@ApiProperty({
description: 'The ID of the policy to claim against.',
example: 1,
})
@IsInt()
@IsPositive()
policyId!: number;
@ApiProperty({
description: 'Claim amount in stroops as an integer string.',
example: '500000000',
})
@IsString()
@Validate(PositiveIntStringConstraint)
amount!: string;
@ApiProperty({
description: 'Narrative description of the claim.',
example: 'Water damage in the kitchen due to pipe burst.',
})
@IsString()
@MaxLength(1000)
details!: string;
@ApiProperty({
description: 'List of IPFS URLs (or CIDs) for evidence images.',
example: ['https://ipfs.io/ipfs/Qm...'],
})
@IsArray()
@IsString({ each: true })
imageUrls!: string[];
}