-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: issuance API with required attribute (#528)
* 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
1 parent
b6e3183
commit 7421fba
Showing
2 changed files
with
168 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
||
} | ||
|
||
|
@@ -87,8 +88,7 @@ export class OOBIssueCredentialDto extends CredentialsIssuanceDto { | |
example: [ | ||
{ | ||
value: 'string', | ||
name: 'string', | ||
isRequired: 'boolean' | ||
name: 'string' | ||
} | ||
] | ||
}) | ||
|
@@ -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' }) | ||
|
@@ -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' }) | ||
|
Oops, something went wrong.