From e82a83c8117d56fbf00ee19bc52e9c6e29d62d62 Mon Sep 17 00:00:00 2001 From: samuel Date: Sun, 11 Feb 2024 09:27:25 +0100 Subject: [PATCH] fix --- apps/authz/src/shared/types/policy.type.ts | 20 +++++++++++-------- .../is-not-empty-array-enum.decorator.ts | 4 ++-- .../is-not-empty-array-string.decorator.ts | 4 ++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/apps/authz/src/shared/types/policy.type.ts b/apps/authz/src/shared/types/policy.type.ts index 340bc00c4..cc54c56c6 100644 --- a/apps/authz/src/shared/types/policy.type.ts +++ b/apps/authz/src/shared/types/policy.type.ts @@ -93,12 +93,13 @@ export class AmountCondition { @IsIn([...Object.values(FiatCurrency), '*']) currency: FiatCurrency | '*' - @IsNotEmpty() @IsEnum(ValueOperators) + @ApiProperty({ enum: ValueOperators }) operator: ValueOperators @IsNotEmpty() @IsNumberString() + @ApiProperty({ type: String }) value: string } @@ -106,22 +107,23 @@ export class ERC1155AmountCondition { @IsAssetId() tokenId: AssetId - @IsNotEmpty() @IsEnum(ValueOperators) + @ApiProperty({ enum: ValueOperators }) operator: ValueOperators @IsNotEmpty() @IsNumberString() + @ApiProperty({ type: String }) value: string } export class SignMessageCondition { - @IsNotEmpty() @IsIn([ValueOperators.EQUAL, IdentityOperators.CONTAINS]) operator: ValueOperators.EQUAL | IdentityOperators.CONTAINS @IsNotEmpty() @IsString() + @ApiProperty({ type: String }) value: string } @@ -147,12 +149,13 @@ export class SignTypedDataDomainCondition { } export class PermitDeadlineCondition { - @IsNotEmpty() @IsEnum(ValueOperators) + @ApiProperty({ enum: ValueOperators }) operator: ValueOperators @IsNotEmpty() @IsNumberString() + @ApiProperty({ type: String }) value: string // timestamp in ms } @@ -167,6 +170,7 @@ export class ApprovalCondition { @IsDefined() @IsIn(Object.values(EntityType)) + @ApiProperty({ enum: Object.values(EntityType) }) approvalEntityType: EntityType @IsNotEmptyArrayString() @@ -221,8 +225,9 @@ export class SpendingLimitFilters { } export class SpendingLimitCondition { - @IsString() @IsNotEmpty() + @IsString() + @ApiProperty({ type: String }) limit: string @IsIn(Object.values(FiatCurrency)) @@ -603,12 +608,11 @@ export type PolicyCriterion = @ApiExtraModels(...SUPPORTED_CRITERION) export class Policy { - @IsDefined() + @IsNotEmpty() @IsString() - @ApiProperty() + @ApiProperty({ type: String }) name: string - @IsDefined() @IsArray() @ValidateNested({ each: true }) @Transform(({ value }) => { diff --git a/packages/authz-shared/src/lib/decorators/is-not-empty-array-enum.decorator.ts b/packages/authz-shared/src/lib/decorators/is-not-empty-array-enum.decorator.ts index 8e3749fa2..f00b8de1c 100644 --- a/packages/authz-shared/src/lib/decorators/is-not-empty-array-enum.decorator.ts +++ b/packages/authz-shared/src/lib/decorators/is-not-empty-array-enum.decorator.ts @@ -1,6 +1,6 @@ import { applyDecorators } from '@nestjs/common' -import { ArrayMinSize, IsArray, IsDefined, IsEnum } from 'class-validator' +import { ArrayMinSize, IsArray, IsEnum, IsNotEmpty } from 'class-validator' export function IsNotEmptyArrayEnum(obj: object) { - return applyDecorators(IsDefined(), IsArray(), IsEnum(obj, { each: true }), ArrayMinSize(1)) + return applyDecorators(IsArray(), IsNotEmpty({ each: true }), IsEnum(obj, { each: true }), ArrayMinSize(1)) } diff --git a/packages/authz-shared/src/lib/decorators/is-not-empty-array-string.decorator.ts b/packages/authz-shared/src/lib/decorators/is-not-empty-array-string.decorator.ts index e77f826d2..452e58fc9 100644 --- a/packages/authz-shared/src/lib/decorators/is-not-empty-array-string.decorator.ts +++ b/packages/authz-shared/src/lib/decorators/is-not-empty-array-string.decorator.ts @@ -1,6 +1,6 @@ import { applyDecorators } from '@nestjs/common' -import { ArrayMinSize, IsArray, IsDefined, IsString } from 'class-validator' +import { ArrayMinSize, IsArray, IsNotEmpty, IsString } from 'class-validator' export function IsNotEmptyArrayString() { - return applyDecorators(IsDefined(), IsArray(), IsString({ each: true }), ArrayMinSize(1)) + return applyDecorators(IsArray(), IsNotEmpty({ each: true }), IsString({ each: true }), ArrayMinSize(1)) }