39 lines
661 B
TypeScript
39 lines
661 B
TypeScript
|
import { object, string, number, optional, pipe, unknown, transform, picklist } from 'valibot'
|
||
|
|
||
|
const personJSONSchema = object({
|
||
|
name: string(),
|
||
|
age: number(),
|
||
|
})
|
||
|
|
||
|
const postJSONSchema = object({
|
||
|
id: number(),
|
||
|
title: string(),
|
||
|
})
|
||
|
|
||
|
const idJSONSchema = object({
|
||
|
id: string(),
|
||
|
})
|
||
|
|
||
|
const queryNameSchema = optional(
|
||
|
object({
|
||
|
name: optional(string()),
|
||
|
})
|
||
|
)
|
||
|
|
||
|
const queryPaginationSchema = object({
|
||
|
page: pipe(unknown(), transform(Number)),
|
||
|
})
|
||
|
|
||
|
const querySortSchema = object({
|
||
|
order: picklist(['asc', 'desc']),
|
||
|
})
|
||
|
|
||
|
export {
|
||
|
idJSONSchema,
|
||
|
personJSONSchema,
|
||
|
postJSONSchema,
|
||
|
queryNameSchema,
|
||
|
queryPaginationSchema,
|
||
|
querySortSchema,
|
||
|
}
|