Skip to content

Commit

Permalink
fix: removed the is not UUID validation in org name
Browse files Browse the repository at this point in the history
Signed-off-by: KulkarniShashank <[email protected]>
  • Loading branch information
KulkarniShashank committed Apr 18, 2024
1 parent da26cd2 commit 16b846d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ApiExtraModels, ApiPropertyOptional } from '@nestjs/swagger';
import { IsNotEmpty, IsOptional, IsString, IsBoolean, MaxLength, MinLength, Validate } from 'class-validator';

import { Transform } from 'class-transformer';
import { ImageBase64Validator, IsNotUUID, trim } from '@credebl/common/cast.helper';
import { ImageBase64Validator, trim } from '@credebl/common/cast.helper';

@ApiExtraModels()
export class UpdateOrganizationDto {
Expand All @@ -17,7 +17,6 @@ export class UpdateOrganizationDto {
@MinLength(2, { message: 'Organization name must be at least 2 characters.' })
@MaxLength(50, { message: 'Organization name must be at most 50 characters.' })
@IsString({ message: 'Organization name must be in string format.' })
@IsNotUUID({message: 'Invalid orgName'})
name: string;

@ApiPropertyOptional()
Expand Down
29 changes: 15 additions & 14 deletions libs/common/src/cast.helper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BadRequestException } from '@nestjs/common';
import { ValidationArguments, ValidationOptions, ValidatorConstraint, ValidatorConstraintInterface, isBase64, isMimeType, isUUID, registerDecorator } from 'class-validator';
import { ValidationArguments, ValidationOptions, ValidatorConstraint, ValidatorConstraintInterface, isBase64, isMimeType, registerDecorator } from 'class-validator';

interface ToNumberOptions {
default?: number;
Expand Down Expand Up @@ -130,16 +130,17 @@ export class ImageBase64Validator implements ValidatorConstraintInterface {
}
}

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);
}
}
});
};
// IS NOT UUID validation
// 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);
// }
// }
// });
// };

0 comments on commit 16b846d

Please sign in to comment.