fix: forbid creation of objects or fields with certain characters or with forbidden keywords that clashes with pg_graphql (#3957)

* fix: forbid creation of objects or fields with certain characters or with forbidden keywords that clashes with pg_graphql

* refactor: add a decorator for name validation and use it on fields
This commit is contained in:
Mohamed Houssein Douici
2024-02-24 12:32:01 +01:00
committed by GitHub
parent b1eb0577bc
commit 0fe838d320
4 changed files with 32 additions and 0 deletions

View File

@ -3,6 +3,7 @@ import { Field, HideField, InputType } from '@nestjs/graphql';
import { BeforeCreateOne } from '@ptc-org/nestjs-query-graphql';
import { IsNotEmpty, IsOptional, IsString, IsUUID } from 'class-validator';
import { IsValidName } from 'src/metadata/decorators/is-valid-name.decorator';
import { BeforeCreateOneObject } from 'src/metadata/object-metadata/hooks/before-create-one-object.hook';
@InputType()
@ -11,11 +12,13 @@ export class CreateObjectInput {
@IsString()
@IsNotEmpty()
@Field()
@IsValidName()
nameSingular: string;
@IsString()
@IsNotEmpty()
@Field()
@IsValidName()
namePlural: string;
@IsString()