@pyreon/validation 0.3.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,51 +0,0 @@
1
- import { SchemaValidateFn, ValidateFn } from "@pyreon/form";
2
-
3
- //#region src/arktype.d.ts
4
- /**
5
- * Internal callable interface matching ArkType's Type.
6
- * Not exposed publicly — consumers pass their ArkType schema directly.
7
- */
8
- interface ArkTypeCallable {
9
- (data: unknown): unknown;
10
- }
11
- /**
12
- * Create a form-level schema validator from an ArkType schema.
13
- *
14
- * Accepts any callable ArkType `Type` instance. The schema is duck-typed —
15
- * no ArkType import required.
16
- *
17
- * @example
18
- * import { type } from 'arktype'
19
- * import { arktypeSchema } from '@pyreon/validation/arktype'
20
- *
21
- * const schema = type({
22
- * email: 'string.email',
23
- * password: 'string >= 8',
24
- * })
25
- *
26
- * const form = useForm({
27
- * initialValues: { email: '', password: '' },
28
- * schema: arktypeSchema(schema),
29
- * onSubmit: (values) => { ... },
30
- * })
31
- */
32
- declare function arktypeSchema<TValues extends Record<string, unknown>>(schema: ArkTypeCallable): SchemaValidateFn<TValues>;
33
- /**
34
- * Create a single-field validator from an ArkType schema.
35
- *
36
- * @example
37
- * import { type } from 'arktype'
38
- * import { arktypeField } from '@pyreon/validation/arktype'
39
- *
40
- * const form = useForm({
41
- * initialValues: { email: '' },
42
- * validators: {
43
- * email: arktypeField(type('string.email')),
44
- * },
45
- * onSubmit: (values) => { ... },
46
- * })
47
- */
48
- declare function arktypeField<T>(schema: ArkTypeCallable): ValidateFn<T>;
49
- //#endregion
50
- export { arktypeField, arktypeSchema };
51
- //# sourceMappingURL=arktype2.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"arktype2.d.ts","names":[],"sources":["../../src/arktype.ts"],"mappings":";;;;;AAIqB;;UAoBX,eAAA;EAAA,CACP,IAAA;AAAA;AAmCH;;;;;;;;;;;;;;;;;AAgCA;;;;AAhCA,iBAAgB,aAAA,iBAA8B,MAAA,kBAAA,CAC5C,MAAA,EAAQ,eAAA,GACP,gBAAA,CAAiB,OAAA;;;;;;;;;;;;;;;;iBA8BJ,YAAA,GAAA,CAAgB,MAAA,EAAQ,eAAA,GAAkB,UAAA,CAAW,CAAA"}
@@ -1,51 +0,0 @@
1
- import { SchemaValidateFn, ValidateFn } from "@pyreon/form";
2
-
3
- //#region src/valibot.d.ts
4
- /**
5
- * Any function that takes (schema, input, ...rest) and returns a parse result.
6
- * Valibot's safeParse/safeParseAsync have generic constraints on the schema
7
- * parameter that can't be expressed without importing Valibot types. We accept
8
- * any callable and cast internally.
9
- */
10
- type GenericSafeParseFn = Function;
11
- /**
12
- * Create a form-level schema validator from a Valibot schema.
13
- *
14
- * Valibot uses standalone functions rather than methods, so you must pass
15
- * the `safeParseAsync` (or `safeParse`) function from valibot.
16
- *
17
- * @example
18
- * import * as v from 'valibot'
19
- * import { valibotSchema } from '@pyreon/validation/valibot'
20
- *
21
- * const schema = v.object({
22
- * email: v.pipe(v.string(), v.email()),
23
- * password: v.pipe(v.string(), v.minLength(8)),
24
- * })
25
- *
26
- * const form = useForm({
27
- * initialValues: { email: '', password: '' },
28
- * schema: valibotSchema(schema, v.safeParseAsync),
29
- * onSubmit: (values) => { ... },
30
- * })
31
- */
32
- declare function valibotSchema<TValues extends Record<string, unknown>>(schema: unknown, safeParseFn: GenericSafeParseFn): SchemaValidateFn<TValues>;
33
- /**
34
- * Create a single-field validator from a Valibot schema.
35
- *
36
- * @example
37
- * import * as v from 'valibot'
38
- * import { valibotField } from '@pyreon/validation/valibot'
39
- *
40
- * const form = useForm({
41
- * initialValues: { email: '' },
42
- * validators: {
43
- * email: valibotField(v.pipe(v.string(), v.email('Invalid email')), v.safeParseAsync),
44
- * },
45
- * onSubmit: (values) => { ... },
46
- * })
47
- */
48
- declare function valibotField<T>(schema: unknown, safeParseFn: GenericSafeParseFn): ValidateFn<T>;
49
- //#endregion
50
- export { valibotField, valibotSchema };
51
- //# sourceMappingURL=valibot2.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"valibot2.d.ts","names":[],"sources":["../../src/valibot.ts"],"mappings":";;;;;AAIqB;;;;KA6BhB,kBAAA,GAAqB,QAAA;AAmC1B;;;;;;;;;;;;;;;;;;AAoCA;;;AApCA,iBAAgB,aAAA,iBAA8B,MAAA,kBAAA,CAC5C,MAAA,WACA,WAAA,EAAa,kBAAA,GACZ,gBAAA,CAAiB,OAAA;;;;;;;;;;;;;;;;iBAiCJ,YAAA,GAAA,CACd,MAAA,WACA,WAAA,EAAa,kBAAA,GACZ,UAAA,CAAW,CAAA"}
@@ -1,71 +0,0 @@
1
- import { SchemaValidateFn, ValidateFn } from "@pyreon/form";
2
-
3
- //#region src/zod.d.ts
4
- /**
5
- * Minimal Zod-compatible interfaces so we don't require zod as a hard dep.
6
- * These match Zod v3's public API surface.
7
- */
8
- interface ZodIssue {
9
- path: PropertyKey[];
10
- message: string;
11
- }
12
- /**
13
- * Duck-typed Zod schema interface — works with both Zod v3 and v4.
14
- * Inlines the result shape to avoid version-specific type mismatches.
15
- */
16
- interface ZodSchema<T = unknown> {
17
- safeParse(data: unknown): {
18
- success: boolean;
19
- data?: T;
20
- error?: {
21
- issues: ZodIssue[];
22
- };
23
- };
24
- safeParseAsync(data: unknown): Promise<{
25
- success: boolean;
26
- data?: T;
27
- error?: {
28
- issues: ZodIssue[];
29
- };
30
- }>;
31
- }
32
- /**
33
- * Create a form-level schema validator from a Zod schema.
34
- * Supports both sync and async Zod schemas (uses `safeParseAsync`).
35
- *
36
- * @example
37
- * import { z } from 'zod'
38
- * import { zodSchema } from '@pyreon/validation/zod'
39
- *
40
- * const schema = z.object({
41
- * email: z.string().email(),
42
- * password: z.string().min(8),
43
- * })
44
- *
45
- * const form = useForm({
46
- * initialValues: { email: '', password: '' },
47
- * schema: zodSchema(schema),
48
- * onSubmit: (values) => { ... },
49
- * })
50
- */
51
- declare function zodSchema<TValues extends Record<string, unknown>>(schema: ZodSchema<TValues>): SchemaValidateFn<TValues>;
52
- /**
53
- * Create a single-field validator from a Zod schema.
54
- * Supports both sync and async Zod refinements.
55
- *
56
- * @example
57
- * import { z } from 'zod'
58
- * import { zodField } from '@pyreon/validation/zod'
59
- *
60
- * const form = useForm({
61
- * initialValues: { email: '' },
62
- * validators: {
63
- * email: zodField(z.string().email('Invalid email')),
64
- * },
65
- * onSubmit: (values) => { ... },
66
- * })
67
- */
68
- declare function zodField<T>(schema: ZodSchema<T>): ValidateFn<T>;
69
- //#endregion
70
- export { zodField, zodSchema };
71
- //# sourceMappingURL=zod2.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"zod2.d.ts","names":[],"sources":["../../src/zod.ts"],"mappings":";;;;;AAIqB;;UAQX,QAAA;EACR,IAAA,EAAM,WAAA;EACN,OAAA;AAAA;;;;AAAO;UAOC,SAAA;EACR,SAAA,CAAU,IAAA;IACR,OAAA;IACA,IAAA,GAAO,CAAA;IACP,KAAA;MAAU,MAAA,EAAQ,QAAA;IAAA;EAAA;EAEpB,cAAA,CACE,IAAA,YACC,OAAA;IAAU,OAAA;IAAkB,IAAA,GAAO,CAAA;IAAG,KAAA;MAAU,MAAA,EAAQ,QAAA;IAAA;EAAA;AAAA;;;;;;;;;;;;;;AA6B7D;;;;;;iBAAgB,SAAA,iBAA0B,MAAA,kBAAA,CACxC,MAAA,EAAQ,SAAA,CAAU,OAAA,IACjB,gBAAA,CAAiB,OAAA;;;;;;;;;;;;;AA+BpB;;;;iBAAgB,QAAA,GAAA,CAAY,MAAA,EAAQ,SAAA,CAAU,CAAA,IAAK,UAAA,CAAW,CAAA"}