Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: DTO validation #682

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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