23 lines
721 B
TypeScript
23 lines
721 B
TypeScript
import z from "zod/v3";
|
|
import { CoreSchema } from "./core.schema";
|
|
|
|
class RolesSchema extends CoreSchema {
|
|
create = z.object({
|
|
role_key: z
|
|
.string()
|
|
.min(3, { message: "Role key phải có ít nhất 3 ký tự." })
|
|
.max(50, { message: "Role key tối đa 50 ký tự." })
|
|
.regex(/^[a-zA-Z0-9_\-]+$/, {
|
|
message: "Role key chỉ được chứa chữ, số, _ hoặc -.",
|
|
}),
|
|
role_name: z
|
|
.string()
|
|
.min(3, { message: "Tên vai trò phải có ít nhất 3 ký tự." })
|
|
.max(100, { message: "Tên vai trò tối đa 100 ký tự." }),
|
|
});
|
|
}
|
|
|
|
export const rolesSchema = new RolesSchema();
|
|
|
|
export type RoleFormData = z.infer<typeof rolesSchema.create>;
|