Skip to content

Commit

Permalink
fix: issuance API with required attribute (#528)
Browse files Browse the repository at this point in the history
* fix:issuance api

Signed-off-by: pranalidhanavade <[email protected]>

* fix:issuance api issue

Signed-off-by: pranalidhanavade <[email protected]>

* fix:sonarlint issues

Signed-off-by: pranalidhanavade <[email protected]>

* fix:requried attribute in issuance api

Signed-off-by: pranalidhanavade <[email protected]>

* fix:requried attributes in csv file

Signed-off-by: pranalidhanavade <[email protected]>

---------

Signed-off-by: pranalidhanavade <[email protected]>
  • Loading branch information
pranalidhanavade authored Feb 22, 2024
1 parent b6e3183 commit 7421fba
Show file tree
Hide file tree
Showing 2 changed files with 168 additions and 115 deletions.
22 changes: 7 additions & 15 deletions apps/api-gateway/src/issuance/dtos/issuance.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ class Attribute {
@Transform(({ value }) => trim(value))
value: string;

@ApiProperty()
@ApiProperty({ default: false })
@IsBoolean()
@IsOptional()
@IsNotEmpty({ message: 'isRequired property is required' })
isRequired: boolean;
isRequired?: boolean = false;

}

Expand Down Expand Up @@ -87,8 +88,7 @@ export class OOBIssueCredentialDto extends CredentialsIssuanceDto {
example: [
{
value: 'string',
name: 'string',
isRequired: 'boolean'
name: 'string'
}
]
})
Expand All @@ -100,14 +100,14 @@ export class OOBIssueCredentialDto extends CredentialsIssuanceDto {
}

class CredentialOffer {
@ApiProperty({ example: [{ 'value': 'string', 'name': 'string', 'isRequired':'boolean' }] })
@ApiProperty({ example: [{ 'value': 'string', 'name': 'string' }] })
@IsNotEmpty({ message: 'Attribute name is required' })
@IsArray({ message: 'Attributes should be an array' })
@ValidateNested({ each: true })
@Type(() => Attribute)
attributes: Attribute[];

@ApiProperty({ example: 'testmail@mailinator.com' })
@ApiProperty({ example: 'testmail@xyz.com' })
@IsEmail({}, { message: 'Please provide a valid email' })
@IsNotEmpty({ message: 'Email is required' })
@IsString({ message: 'Email should be a string' })
Expand Down Expand Up @@ -212,22 +212,14 @@ export class CredentialAttributes {
}

export class OOBCredentialDtoWithEmail {
@ApiProperty({ example: [{ 'emailId': '[email protected]', 'attributes': [{ 'value': 'string', 'name': 'string', 'isRequired':'boolean' }] }] })
@ApiProperty({ example: [{ 'emailId': '[email protected]', 'attributes': [{ 'value': 'string', 'name': 'string' }] }] })
@IsNotEmpty({ message: 'Please provide valid attributes' })
@IsArray({ message: 'attributes should be array' })
@ArrayMaxSize(Number(process.env.OOB_BATCH_SIZE), { message: `Limit reached (${process.env.OOB_BATCH_SIZE} credentials max). Easily handle larger batches via seamless CSV file uploads` })
@ValidateNested({ each: true })
@Type(() => CredentialOffer)
credentialOffer: CredentialOffer[];

@ApiProperty({ example: '[email protected]' })
@IsEmail({}, { message: 'Please provide a valid email' })
@IsNotEmpty({ message: 'Please provide valid email' })
@IsString({ message: 'email should be string' })
@Transform(({ value }) => value.trim().toLowerCase())
@IsOptional()
emailId: string;

@ApiProperty({ example: 'string' })
@IsNotEmpty({ message: 'Please provide valid credential definition id' })
@IsString({ message: 'credential definition id should be string' })
Expand Down
Loading

0 comments on commit 7421fba

Please sign in to comment.