refactor(validators): frontend to new schema
This commit is contained in:
@ -1,14 +1,15 @@
|
|||||||
import {
|
import {
|
||||||
type InferOutput,
|
type InferOutput,
|
||||||
null as Null,
|
|
||||||
array,
|
array,
|
||||||
nullable,
|
nullable,
|
||||||
object,
|
object,
|
||||||
parse,
|
parse,
|
||||||
pipe,
|
pipe,
|
||||||
string,
|
string,
|
||||||
undefinedable,
|
null_,
|
||||||
uuid,
|
uuid,
|
||||||
|
literal,
|
||||||
|
variant,
|
||||||
} from "valibot";
|
} from "valibot";
|
||||||
|
|
||||||
type BaseRequestParams = Partial<{
|
type BaseRequestParams = Partial<{
|
||||||
@ -56,60 +57,26 @@ const locationValidator = object({
|
|||||||
Description: nullable(string()),
|
Description: nullable(string()),
|
||||||
});
|
});
|
||||||
|
|
||||||
const getUserImagesResponseValidator = array(
|
const eventValidator = object({
|
||||||
object({
|
|
||||||
ID: pipe(string(), uuid()),
|
|
||||||
Image: object({
|
|
||||||
ID: pipe(string(), uuid()),
|
|
||||||
ImageName: string(),
|
|
||||||
Image: Null(),
|
|
||||||
}),
|
|
||||||
Tags: nullable(
|
|
||||||
array(
|
|
||||||
object({
|
|
||||||
ID: pipe(string(), uuid()),
|
|
||||||
TagID: pipe(string(), uuid()),
|
|
||||||
ImageID: pipe(string(), uuid()),
|
|
||||||
|
|
||||||
Tag: object({
|
|
||||||
ID: pipe(string(), uuid()),
|
|
||||||
Tag: string(),
|
|
||||||
UserID: pipe(string(), uuid()),
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Links: nullable(
|
|
||||||
array(
|
|
||||||
object({
|
|
||||||
ID: pipe(string(), uuid()),
|
|
||||||
Link: string(),
|
|
||||||
ImageID: pipe(string(), uuid()),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text: nullable(
|
|
||||||
array(
|
|
||||||
object({
|
|
||||||
ID: pipe(string(), uuid()),
|
|
||||||
ImageText: string(),
|
|
||||||
ImageID: pipe(string(), uuid()),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Locations: nullable(array(locationValidator)),
|
|
||||||
Events: nullable(
|
|
||||||
array(
|
|
||||||
object({
|
|
||||||
ID: pipe(string(), uuid()),
|
ID: pipe(string(), uuid()),
|
||||||
Name: string(),
|
Name: string(),
|
||||||
Description: nullable(string()),
|
Description: nullable(string()),
|
||||||
Location: nullable(locationValidator),
|
LocationID: nullable(pipe(string(), uuid())),
|
||||||
}),
|
Location: null_(),
|
||||||
),
|
});
|
||||||
),
|
|
||||||
}),
|
const locationDataType = object({
|
||||||
);
|
type: literal("location"),
|
||||||
|
data: locationValidator,
|
||||||
|
});
|
||||||
|
|
||||||
|
const eventDataType = object({
|
||||||
|
type: literal("event"),
|
||||||
|
data: eventValidator,
|
||||||
|
});
|
||||||
|
|
||||||
|
const dataTypeValidator = variant("type", [locationDataType, eventDataType]);
|
||||||
|
const getUserImagesResponseValidator = array(dataTypeValidator);
|
||||||
|
|
||||||
export const getUserImages = async (): Promise<
|
export const getUserImages = async (): Promise<
|
||||||
InferOutput<typeof getUserImagesResponseValidator>
|
InferOutput<typeof getUserImagesResponseValidator>
|
||||||
|
Reference in New Issue
Block a user