Skip to content

Commit

Permalink
Merge pull request credebl#682 from credebl/fix/dto-validations
Browse files Browse the repository at this point in the history
  • Loading branch information
sairanjit authored Apr 25, 2024
2 parents 554096c + 2357e63 commit d880598
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
30 changes: 15 additions & 15 deletions apps/api-gateway/src/dtos/send-proof-request.dto.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsArray, IsString, IsNotEmpty, IsObject} from 'class-validator';
import { IsArray, IsString, IsNotEmpty, IsObject } from 'class-validator';


export class SendProofRequest {
export class SendProofRequest {
@ApiProperty({ 'example': '3fa85f64-5717-4562-b3fc-2c963f66afa6' })
@IsString({message:'connection id must be string'})
@IsNotEmpty({message:'please provide valid connection Id'})
@IsString({ message: 'connection id must be string' })
@IsNotEmpty({ message: 'please provide valid connection Id' })
connectionId: string;

@ApiProperty({
'example': [
{
attributeName: 'attributeName',
condition: '>=',
value: 'predicates',
credDefId: '',
credentialName:''
}
]
{
attributeName: 'attributeName',
condition: '>=',
value: 'predicates',
credDefId: '',
credentialName: ''
}
]
})
@IsArray({message:'attributes must be in array'})
@IsObject({each:true})
@IsNotEmpty({message:'please provide valid attributes'})
@IsArray({ message: 'attributes must be in array' })
@IsObject({ each: true })
@IsNotEmpty({ message: 'please provide valid attributes' })
attributes: object[];
}
5 changes: 3 additions & 2 deletions apps/api-gateway/src/issuance/dtos/issuance.dto.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/array-type */

import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { ArrayMaxSize, ArrayMinSize, IsArray, IsBoolean, IsDefined, IsEmail, IsEnum, IsNotEmpty, IsObject, IsOptional, IsString, MaxLength, ValidateNested } from 'class-validator';
import { ArrayMaxSize, ArrayMinSize, IsArray, IsBoolean, IsDefined, IsEmail, IsEnum, IsNotEmpty, IsObject, IsOptional, IsString, MaxLength, ValidateIf, ValidateNested } from 'class-validator';
import { IsCredentialJsonLdContext, SingleOrArray } from '../utils/helper';
import { IssueCredentialType, JsonLdCredentialDetailCredentialStatusOptions, JsonLdCredentialDetailOptionsOptions, JsonObject } from '../interfaces';
import { Transform, Type } from 'class-transformer';
Expand Down Expand Up @@ -125,6 +125,7 @@ export class Attribute {

}
export class CredentialsIssuanceDto {
@ValidateIf((obj) => obj.credentialType === IssueCredentialType.INDY)
@ApiProperty({ example: 'string' })
@IsNotEmpty({ message: 'Credential definition Id is required' })
@IsString({ message: 'Credential definition id should be string' })
Expand Down Expand Up @@ -221,7 +222,7 @@ export class OOBIssueCredentialDto extends CredentialsIssuanceDto {
@IsNotEmpty()
@IsBoolean({message: 'isShortenUrl must be boolean'})
isShortenUrl?: boolean;


@ApiProperty()
@IsNotEmpty({ message: 'Please provide valid credential' })
Expand Down

0 comments on commit d880598

Please sign in to comment.