Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
samteb committed Feb 11, 2024
1 parent 40441f9 commit e82a83c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
20 changes: 12 additions & 8 deletions apps/authz/src/shared/types/policy.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,35 +93,37 @@ export class AmountCondition {
@IsIn([...Object.values(FiatCurrency), '*'])
currency: FiatCurrency | '*'

@IsNotEmpty()
@IsEnum(ValueOperators)
@ApiProperty({ enum: ValueOperators })
operator: ValueOperators

@IsNotEmpty()
@IsNumberString()
@ApiProperty({ type: String })
value: string
}

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
}

Expand All @@ -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
}

Expand All @@ -167,6 +170,7 @@ export class ApprovalCondition {

@IsDefined()
@IsIn(Object.values(EntityType))
@ApiProperty({ enum: Object.values(EntityType) })
approvalEntityType: EntityType

@IsNotEmptyArrayString()
Expand Down Expand Up @@ -221,8 +225,9 @@ export class SpendingLimitFilters {
}

export class SpendingLimitCondition {
@IsString()
@IsNotEmpty()
@IsString()
@ApiProperty({ type: String })
limit: string

@IsIn(Object.values(FiatCurrency))
Expand Down Expand Up @@ -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 }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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))
}
Original file line number Diff line number Diff line change
@@ -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))
}

0 comments on commit e82a83c

Please sign in to comment.