add constraint
This commit is contained in:
@@ -11,9 +11,12 @@ import {
|
||||
} from 'class-validator';
|
||||
import { toNumber } from 'lodash';
|
||||
|
||||
import { IsUnique } from '@/modules/core/constraints/unique.constraint';
|
||||
import { DtoValidation } from '@/modules/core/decorator/dto.validation.decorator';
|
||||
import { PaginateOptions } from '@/modules/database/types';
|
||||
|
||||
import { TagEntity } from '../entities';
|
||||
|
||||
@DtoValidation({ type: 'query' })
|
||||
export class QueryTagDto implements PaginateOptions {
|
||||
@Transform(({ value }) => toNumber(value))
|
||||
@@ -31,6 +34,7 @@ export class QueryTagDto implements PaginateOptions {
|
||||
|
||||
@DtoValidation({ groups: ['create'] })
|
||||
export class CreateTagDto {
|
||||
@IsUnique(TagEntity, { groups: ['create'], message: 'The label names are repeated' })
|
||||
@MaxLength(255, {
|
||||
always: true,
|
||||
message: 'The maximum length of the label name is $constraint1',
|
||||
|
||||
Reference in New Issue
Block a user