feat: frontend validation
This commit is contained in:
@ -3,6 +3,7 @@ import { fetch } from "@tauri-apps/plugin-http";
|
|||||||
import {
|
import {
|
||||||
type InferOutput,
|
type InferOutput,
|
||||||
array,
|
array,
|
||||||
|
enum_,
|
||||||
literal,
|
literal,
|
||||||
null_,
|
null_,
|
||||||
nullable,
|
nullable,
|
||||||
@ -10,6 +11,7 @@ import {
|
|||||||
pipe,
|
pipe,
|
||||||
strictObject,
|
strictObject,
|
||||||
string,
|
string,
|
||||||
|
union,
|
||||||
uuid,
|
uuid,
|
||||||
variant,
|
variant,
|
||||||
} from "valibot";
|
} from "valibot";
|
||||||
@ -165,11 +167,24 @@ const userImageValidator = strictObject({
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const userProcessingImageValidator = strictObject({
|
||||||
|
ID: pipe(string(), uuid()),
|
||||||
|
ImageID: pipe(string(), uuid()),
|
||||||
|
UserID: pipe(string(), uuid()),
|
||||||
|
Image: strictObject({
|
||||||
|
ID: pipe(string(), uuid()),
|
||||||
|
ImageName: string(),
|
||||||
|
Image: null_(),
|
||||||
|
}),
|
||||||
|
Status: union([literal("not-started"), literal("in-progress")]),
|
||||||
|
});
|
||||||
|
|
||||||
export type UserImage = InferOutput<typeof dataTypeValidator>;
|
export type UserImage = InferOutput<typeof dataTypeValidator>;
|
||||||
|
|
||||||
const imageRequestValidator = strictObject({
|
const imageRequestValidator = strictObject({
|
||||||
UserImages: array(userImageValidator),
|
UserImages: array(userImageValidator),
|
||||||
ImageProperties: array(dataTypeValidator),
|
ImageProperties: array(dataTypeValidator),
|
||||||
|
ProcessingImages: array(userProcessingImageValidator),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const getUserImages = async (): Promise<
|
export const getUserImages = async (): Promise<
|
||||||
|
Reference in New Issue
Block a user