43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
/**
|
|
* Interface of the server (auto-generated code)
|
|
*/
|
|
import { z as zod } from "zod";
|
|
|
|
|
|
export const ZodUserCreate = zod.object({
|
|
login: zod.string().min(3).max(128),
|
|
email: zod.string().min(5).max(128),
|
|
password: zod.string().min(128).max(128),
|
|
|
|
});
|
|
|
|
export type UserCreate = zod.infer<typeof ZodUserCreate>;
|
|
|
|
export function isUserCreate(data: any): data is UserCreate {
|
|
try {
|
|
ZodUserCreate.parse(data);
|
|
return true;
|
|
} catch (e: any) {
|
|
console.log(`Fail to parse data type='ZodUserCreate' error=${e}`);
|
|
return false;
|
|
}
|
|
}
|
|
export const ZodUserCreateWrite = zod.object({
|
|
login: zod.string().min(3).max(128).optional(),
|
|
email: zod.string().min(5).max(128).optional(),
|
|
password: zod.string().min(128).max(128).optional(),
|
|
|
|
});
|
|
|
|
export type UserCreateWrite = zod.infer<typeof ZodUserCreateWrite>;
|
|
|
|
export function isUserCreateWrite(data: any): data is UserCreateWrite {
|
|
try {
|
|
ZodUserCreateWrite.parse(data);
|
|
return true;
|
|
} catch (e: any) {
|
|
console.log(`Fail to parse data type='ZodUserCreateWrite' error=${e}`);
|
|
return false;
|
|
}
|
|
}
|