karso/front/src/back-api/model/user-auth.ts

58 lines
1.6 KiB
TypeScript

/**
* Interface of the server (auto-generated code)
*/
import { z as zod } from "zod";
import {ZodTimestamp} from "./timestamp";
import {ZodLong} from "./long";
import {ZodUser, ZodUserWrite } from "./user";
export const ZodUserAuth = ZodUser.extend({
password: zod.string().min(128).max(128).optional(),
email: zod.string().min(5).max(128),
emailValidate: ZodTimestamp.optional(),
newEmail: zod.string().min(5).max(128).optional(),
avatar: zod.boolean(),
/**
* List of accessible application (if not set the application is not available)
*/
applications: zod.array(ZodLong),
});
export type UserAuth = zod.infer<typeof ZodUserAuth>;
export function isUserAuth(data: any): data is UserAuth {
try {
ZodUserAuth.parse(data);
return true;
} catch (e: any) {
console.log(`Fail to parse data type='ZodUserAuth' error=${e}`);
return false;
}
}
export const ZodUserAuthWrite = ZodUserWrite.extend({
password: zod.string().min(128).max(128).nullable().optional(),
email: zod.string().min(5).max(128).optional(),
emailValidate: ZodTimestamp.nullable().optional(),
newEmail: zod.string().min(5).max(128).nullable().optional(),
avatar: zod.boolean().optional(),
/**
* List of accessible application (if not set the application is not available)
*/
applications: zod.array(ZodLong).optional(),
});
export type UserAuthWrite = zod.infer<typeof ZodUserAuthWrite>;
export function isUserAuthWrite(data: any): data is UserAuthWrite {
try {
ZodUserAuthWrite.parse(data);
return true;
} catch (e: any) {
console.log(`Fail to parse data type='ZodUserAuthWrite' error=${e}`);
return false;
}
}