chore(deps): add zod and nestjs-zod for schema validation
This commit is contained in:
@@ -1,46 +1,24 @@
|
||||
import { IsString, IsNotEmpty, IsNumber, IsOptional, IsBoolean, Min, Max } from 'class-validator';
|
||||
import { z } from "zod";
|
||||
|
||||
export class GenerateSerialDto {
|
||||
@IsString()
|
||||
@IsNotEmpty({ message: '企业名称不能为空' })
|
||||
companyName: string;
|
||||
export const GenerateSerialDto = z.object({
|
||||
companyName: z.string().min(1, "企业名称不能为空"),
|
||||
quantity: z.number().min(1).max(100).optional(),
|
||||
validDays: z.number().optional(),
|
||||
});
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@Min(1)
|
||||
@Max(100)
|
||||
quantity?: number;
|
||||
export const GenerateWithPrefixDto = GenerateSerialDto.extend({
|
||||
serialPrefix: z.string().min(1, "自定义前缀不能为空"),
|
||||
});
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
validDays?: number;
|
||||
}
|
||||
export const QRCodeDto = z.object({
|
||||
baseUrl: z.string().optional(),
|
||||
});
|
||||
|
||||
export class GenerateWithPrefixDto extends GenerateSerialDto {
|
||||
@IsString()
|
||||
@IsNotEmpty({ message: '自定义前缀不能为空' })
|
||||
serialPrefix: string;
|
||||
}
|
||||
|
||||
export class QRCodeDto {
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
baseUrl?: string;
|
||||
}
|
||||
|
||||
export class UpdateSerialDto {
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
companyName?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
validUntil?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
isActive?: boolean;
|
||||
}
|
||||
export const UpdateSerialDto = z.object({
|
||||
companyName: z.string().optional(),
|
||||
validUntil: z.string().optional(),
|
||||
isActive: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export interface Serial {
|
||||
id: number;
|
||||
|
||||
Reference in New Issue
Block a user