|
1 | | -import type { Schema as JoiSchema } from 'joi' |
2 | | -import type { Struct } from 'superstruct' |
3 | | -import type { BaseIssue, BaseSchema as ValibotSchema } from 'valibot' |
| 1 | +import type { Schema } from 'joi' |
4 | 2 | import type { ComputedRef, Ref } from 'vue' |
5 | | -import type { ObjectSchema as YupSchema } from 'yup' |
6 | | -import type { ZodSchema } from 'zod' |
7 | 3 |
|
8 | | -export type Awaitable<T> = T | PromiseLike<T> |
| 4 | +type AnyObject = Record<string, any> |
9 | 5 |
|
| 6 | +interface ZodSchema<F> extends AnyObject { |
| 7 | + shape: Record<keyof F, unknown> |
| 8 | +} |
| 9 | +interface YupSchema<F> extends AnyObject { |
| 10 | + fields: Record<keyof F, unknown> |
| 11 | +} |
| 12 | +interface ValibotSchema<F> extends AnyObject { |
| 13 | + entries: Record<keyof F, unknown> |
| 14 | +} |
| 15 | +// interface JoiTerms<F> extends AnyObject { |
| 16 | +// keys: Array<{ key: keyof F, schema: unknown }> |
| 17 | +// } |
| 18 | +// interface JoiSchema<F> extends AnyObject { |
| 19 | +// $_terms: JoiTerms<F> |
| 20 | +// } |
| 21 | +interface SuperstructSchema<F> extends AnyObject { |
| 22 | + schema: Record<keyof F, unknown> |
| 23 | +} |
| 24 | + |
| 25 | +export type Awaitable<T> = T | PromiseLike<T> |
10 | 26 | export type FieldErrors<F> = Partial<Record<keyof F, string>> |
11 | 27 | export type Form = Record<string, unknown> |
12 | 28 | export type GetErrorsFn<S, F extends Form> = (schema: S, form: F) => Awaitable<FieldErrors<F>> |
13 | 29 |
|
14 | | -export type Schema<F extends Form> = |
15 | | - | ZodSchema |
| 30 | +export type InputSchema<F extends Form> = |
| 31 | + | ZodSchema<F> |
16 | 32 | | YupSchema<F> |
17 | | - | ValibotSchema<unknown, unknown, BaseIssue<unknown>> |
18 | | - | JoiSchema |
19 | | - | Struct<F> |
| 33 | + | ValibotSchema<F> |
| 34 | + | Schema<F> |
| 35 | + | SuperstructSchema<F> |
20 | 36 |
|
21 | 37 | export interface ReturnType<F> { |
22 | 38 | validate: () => Promise<FieldErrors<F>> |
|
0 commit comments