Skip to content

Commit

Permalink
Merge pull request #710 from credebl/fix/get-verification-by-schemaId
Browse files Browse the repository at this point in the history
fix: Unable to get credDef for schemaId with surrounding spaces
  • Loading branch information
GHkrishna authored May 16, 2024
2 parents 02a1ce8 + e9b3606 commit e3dfbd3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { CreateCredentialDefinitionDto } from './dto/create-cred-defs.dto';
import { OrgRoles } from 'libs/org-roles/enums';
import { Roles } from '../authz/decorators/roles.decorator';
import { CustomExceptionFilter } from 'apps/api-gateway/common/exception-handler';
import { TrimStringParamPipe } from '@credebl/common/cast.helper';


@ApiBearerAuth()
Expand Down Expand Up @@ -59,7 +60,7 @@ export class CredentialDefinitionController {
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
@UseGuards(AuthGuard('jwt'))
async getCredentialDefinitionBySchemaId(
@Param('schemaId') schemaId: string,
@Param('schemaId', TrimStringParamPipe) schemaId: string,
@Res() res: Response
): Promise<Response> {

Expand Down
23 changes: 22 additions & 1 deletion libs/common/src/cast.helper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BadRequestException } from '@nestjs/common';
import { BadRequestException, PipeTransform } from '@nestjs/common';
import { plainToClass } from 'class-transformer';
import {
ValidationArguments,
ValidationOptions,
Expand Down Expand Up @@ -140,6 +141,26 @@ export class ImageBase64Validator implements ValidatorConstraintInterface {
}
}

export class TrimStringParamPipe implements PipeTransform {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type
transform(value: string) {
return plainToClass(String, value.trim());
}
}

// export const IsNotUUID = (validationOptions?: ValidationOptions): PropertyDecorator => (object: object, propertyName: string) => {
// registerDecorator({
// name: 'isNotUUID',
// target: object.constructor,
// propertyName,
// options: validationOptions,
// validator: {
// validate(value) {
// return !isUUID(value);
// }
// }
// });
// };
export class AgentSpinupValidator {
private static validateField(value: string, errorMessage: string): void {
if (!value) {
Expand Down

0 comments on commit e3dfbd3

Please sign in to comment.