Skip to content

Commit a1c38ea

Browse files
bhavanakarwadeKambleSahil3
authored andcommitted
refactor: schema data type validations (#1174)
* wip: support nested attributes while creating schema Signed-off-by: bhavanakarwade <[email protected]> * wip: aligned issuance functionality with nested attributes structure Signed-off-by: bhavanakarwade <[email protected]> * refactor: modify csv to json function Signed-off-by: bhavanakarwade <[email protected]> * fix: formatting changes Signed-off-by: bhavanakarwade <[email protected]> * fix: resolved sonar cloud issue Signed-off-by: bhavanakarwade <[email protected]> * fix: security hotspot issue Signed-off-by: bhavanakarwade <[email protected]> * feat: added schema builder function Signed-off-by: bhavanakarwade <[email protected]> * fix: resolved issue Signed-off-by: bhavanakarwade <[email protected]> * refactor: modify extract attributes function Signed-off-by: bhavanakarwade <[email protected]> * fix: destructured objects Signed-off-by: bhavanakarwade <[email protected]> * feat: added description property Signed-off-by: bhavanakarwade <[email protected]> * fix: added validations for schema type Signed-off-by: bhavanakarwade <[email protected]> * formatted enum file Signed-off-by: bhavanakarwade <[email protected]> * chore: added enum for indy schema data type Signed-off-by: bhavanakarwade <[email protected]> --------- Signed-off-by: bhavanakarwade <[email protected]> Signed-off-by: Sahil Kamble <[email protected]>
1 parent 5510042 commit a1c38ea

File tree

2 files changed

+164
-148
lines changed

2 files changed

+164
-148
lines changed

apps/api-gateway/src/dtos/create-schema.dto.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
import { ApiExtraModels, ApiProperty, ApiPropertyOptional, getSchemaPath } from '@nestjs/swagger';
1818
import { plainToClass, Transform, Type } from 'class-transformer';
1919
import { IsNotSQLInjection, trim } from '@credebl/common/cast.helper';
20-
import { JSONSchemaType, SchemaTypeEnum, W3CSchemaDataType } from '@credebl/enum/enum';
20+
import { IndySchemaDataType, JSONSchemaType, SchemaTypeEnum, W3CSchemaDataType } from '@credebl/enum/enum';
2121

2222
export class W3CAttributeValue {
2323
@ApiProperty()
@@ -37,7 +37,9 @@ export class W3CAttributeValue {
3737
enum: W3CSchemaDataType,
3838
example: W3CSchemaDataType.STRING
3939
})
40-
@IsEnum(W3CSchemaDataType, { message: 'Schema data type must be a valid type' })
40+
@IsEnum(W3CSchemaDataType, {
41+
message: `Schema data type must be one of [${Object.values(W3CSchemaDataType).join(', ')}]`
42+
})
4143
schemaDataType: W3CSchemaDataType;
4244

4345
@ApiProperty()
@@ -205,11 +207,17 @@ class AttributeValue {
205207
@IsNotEmpty({ message: 'attributeName is required' })
206208
attributeName: string;
207209

208-
@ApiProperty()
210+
@ApiProperty({
211+
description: 'The type of the schema',
212+
enum: IndySchemaDataType,
213+
example: IndySchemaDataType.STRING
214+
})
209215
@IsString()
210216
@Transform(({ value }) => trim(value))
211-
@IsNotEmpty({ message: 'schemaDataType is required' })
212-
schemaDataType: string;
217+
@IsEnum(IndySchemaDataType, {
218+
message: `Schema data type must be one of [${Object.values(IndySchemaDataType).join(', ')}]`
219+
})
220+
schemaDataType: IndySchemaDataType;
213221

214222
@ApiProperty()
215223
@IsString()

0 commit comments

Comments
 (0)