@zod-utils/core 7.0.1 → 7.2.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.
package/README.md CHANGED
@@ -23,6 +23,8 @@ npm install @zod-utils/core zod
23
23
  ## Features
24
24
 
25
25
  - **Extract defaults** - Get default values from Zod schemas
26
+ - **Extract meta** - Get `.meta()` property values from schema fields
27
+ - **Merge defaults with meta** - Combine defaults and meta into a single result
26
28
  - **Check validation requirements** - Determine if fields will error on empty input
27
29
  - **Extract validation checks** - Get all validation constraints (min/max, formats, patterns, etc.)
28
30
  - **Schema utilities** - Unwrap and manipulate schema types
@@ -83,6 +85,9 @@ npm install @zod-utils/core zod
83
85
  - [With Transforms](#with-transforms-2)
84
86
  - [`extendWithMeta(field, transform)`](#extendwithmetafield-transform)
85
87
  - [Use Case: Shared Field Definitions with i18n](#use-case-shared-field-definitions-with-i18n)
88
+ - [`extractMeta(field, metaKey)`](#extractmetafield-metakey)
89
+ - [`getSchemaMeta(params, metaKey)`](#getschemametaparams-metakey)
90
+ - [`getMergedSchemaDefaults(params, metaKey)`](#getmergedschemadefaultsparams-metakey)
86
91
  - [`toFieldSelector(props)`](#tofieldselectorprops)
87
92
  - [Type Utilities](#type-utilities)
88
93
  - [`Simplify<T>`](#simplifyt)
@@ -690,6 +695,32 @@ getFieldChecks(
690
695
  // [{ check: 'min_length', ... }, { check: 'max_length', ... }]
691
696
  ```
692
697
 
698
+ #### Union Types
699
+
700
+ ```typescript
701
+ // Collects checks from all union options
702
+ getFieldChecks(z.union([z.string().min(3), z.string().email()]));
703
+ // [{ check: 'min_length', minimum: 3, ... }, { check: 'string_format', format: 'email', ... }]
704
+
705
+ // Works with nullable/optional unions
706
+ getFieldChecks(z.string().min(5).nullable());
707
+ // [{ check: 'min_length', minimum: 5, ... }]
708
+ ```
709
+
710
+ #### Format Types (Zod v4)
711
+
712
+ ```typescript
713
+ // Format types (ZodURL, ZodEmail, ZodUUID, etc.) are fully supported
714
+ getFieldChecks(z.email());
715
+ // [{ check: 'string_format', format: 'email', ... }]
716
+
717
+ getFieldChecks(z.url());
718
+ // [{ check: 'string_format', format: 'url', ... }]
719
+
720
+ getFieldChecks(z.uuid());
721
+ // [{ check: 'string_format', format: 'uuid', ... }]
722
+ ```
723
+
693
724
  #### No Constraints
694
725
 
695
726
  ```typescript
@@ -978,6 +1009,145 @@ const editFormSchema = z.object({
978
1009
 
979
1010
  ---
980
1011
 
1012
+ ### `extractMeta(field, metaKey)`
1013
+
1014
+ Extract the value of a specific meta key from a Zod field. Recursively unwraps optional, nullable, default, transform, and union layers.
1015
+
1016
+ For `ZodObject` fields: if the object's own meta contains the target key, returns that value directly. Otherwise, recurses into shape children and returns a nested record.
1017
+
1018
+ ```typescript
1019
+ import { extractMeta } from "@zod-utils/core";
1020
+ import { z } from "zod";
1021
+
1022
+ // Basic extraction
1023
+ const field = z.string().meta({ label: "Name" });
1024
+ extractMeta(field, "label"); // 'Name'
1025
+
1026
+ // Unwraps through optional/nullable/default
1027
+ extractMeta(z.string().meta({ label: "Name" }).optional(), "label"); // 'Name'
1028
+ extractMeta(z.string().meta({ label: "Name" }).nullable(), "label"); // 'Name'
1029
+ extractMeta(z.string().meta({ label: "Name" }).default("hi"), "label"); // 'Name'
1030
+
1031
+ // Nested objects: recurses when parent lacks the key
1032
+ const address = z.object({
1033
+ city: z.string().meta({ label: "City" }),
1034
+ zip: z.string().meta({ label: "Zip" }),
1035
+ });
1036
+ extractMeta(address, "label"); // { city: 'City', zip: 'Zip' }
1037
+
1038
+ // Object's own meta stops recursion
1039
+ const labeled = address.meta({ label: "Address" });
1040
+ extractMeta(labeled, "label"); // 'Address'
1041
+
1042
+ // Arrays: wraps element meta in an array
1043
+ extractMeta(z.array(z.string().meta({ label: "Tag" })), "label"); // ['Tag']
1044
+
1045
+ // No meta returns undefined
1046
+ extractMeta(z.string(), "label"); // undefined
1047
+ ```
1048
+
1049
+ ---
1050
+
1051
+ ### `getSchemaMeta(params, metaKey)`
1052
+
1053
+ Extract the value of a specific meta key from all fields in a Zod schema. Supports discriminated unions via the `discriminator` parameter.
1054
+
1055
+ ```typescript
1056
+ import { getSchemaMeta } from "@zod-utils/core";
1057
+ import { z } from "zod";
1058
+
1059
+ const schema = z.object({
1060
+ name: z.string().meta({ label: "Name" }),
1061
+ age: z.number().meta({ label: "Age" }),
1062
+ bio: z.string(), // no meta
1063
+ });
1064
+
1065
+ getSchemaMeta({ schema }, "label");
1066
+ // { name: 'Name', age: 'Age' }
1067
+
1068
+ // With discriminated union
1069
+ const formSchema = z.discriminatedUnion("mode", [
1070
+ z.object({
1071
+ mode: z.literal("create"),
1072
+ name: z.string().meta({ label: "Name" }),
1073
+ }),
1074
+ z.object({
1075
+ mode: z.literal("edit"),
1076
+ id: z.number().meta({ label: "ID" }),
1077
+ }),
1078
+ ]);
1079
+
1080
+ getSchemaMeta(
1081
+ { schema: formSchema, discriminator: { key: "mode", value: "create" } },
1082
+ "label"
1083
+ );
1084
+ // { name: 'Name' }
1085
+
1086
+ // With transforms
1087
+ const transformed = z
1088
+ .object({ name: z.string().meta({ label: "Name" }) })
1089
+ .transform((data) => ({ ...data, computed: true }));
1090
+
1091
+ getSchemaMeta({ schema: transformed }, "label");
1092
+ // { name: 'Name' }
1093
+ ```
1094
+
1095
+ ---
1096
+
1097
+ ### `getMergedSchemaDefaults(params, metaKey)`
1098
+
1099
+ Combines schema defaults and meta values into a single result. Meta values take precedence over defaults where both exist. Performs a deep merge for nested objects.
1100
+
1101
+ ```typescript
1102
+ import { getMergedSchemaDefaults } from "@zod-utils/core";
1103
+ import { z } from "zod";
1104
+
1105
+ const schema = z.object({
1106
+ name: z.string().meta({ label: "Name" }).default("hello"),
1107
+ age: z.number().meta({ label: "Age" }),
1108
+ bio: z.string().default(""),
1109
+ });
1110
+
1111
+ getMergedSchemaDefaults({ schema }, "label");
1112
+ // { name: 'Name', age: 'Age', bio: '' }
1113
+ // 'name': meta 'Name' wins over default 'hello'
1114
+ // 'age': only meta exists
1115
+ // 'bio': only default exists
1116
+
1117
+ // Deep merge preserves nested fields from both sources
1118
+ const nested = z.object({
1119
+ address: z.object({
1120
+ city: z.string().meta({ label: "City" }).default("NYC"),
1121
+ zip: z.string().default("00000"),
1122
+ state: z.string().meta({ label: "State" }),
1123
+ }),
1124
+ });
1125
+
1126
+ getMergedSchemaDefaults({ schema: nested }, "label");
1127
+ // { address: { city: 'City', zip: '00000', state: 'State' } }
1128
+
1129
+ // Works with discriminated unions
1130
+ const formSchema = z.discriminatedUnion("mode", [
1131
+ z.object({
1132
+ mode: z.literal("create"),
1133
+ name: z.string().meta({ label: "Name" }).default("New User"),
1134
+ count: z.number().default(0),
1135
+ }),
1136
+ z.object({
1137
+ mode: z.literal("edit"),
1138
+ id: z.number().meta({ label: "ID" }),
1139
+ }),
1140
+ ]);
1141
+
1142
+ getMergedSchemaDefaults(
1143
+ { schema: formSchema, discriminator: { key: "mode", value: "create" } },
1144
+ "label"
1145
+ );
1146
+ // { name: 'Name', count: 0 }
1147
+ ```
1148
+
1149
+ ---
1150
+
981
1151
  ### `toFieldSelector(props)`
982
1152
 
983
1153
  Extracts a `FieldSelector` from props containing schema, name, and optional discriminator. Encapsulates type assertion so callers don't need eslint-disable.
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as z from 'zod';
2
2
  import { z as z$1, util } from 'zod';
3
- import { SomeType, $InferUnionInput, $ZodCheckLessThanDef, $ZodCheckGreaterThanDef, $ZodCheckMultipleOfDef, $ZodCheckNumberFormatDef, $ZodCheckBigIntFormatDef, $ZodCheckMaxSizeDef, $ZodCheckMinSizeDef, $ZodCheckSizeEqualsDef, $ZodCheckMaxLengthDef, $ZodCheckMinLengthDef, $ZodCheckLengthEqualsDef, $ZodCheckStringFormatDef, $ZodCheckRegexDef, $ZodCheckLowerCaseDef, $ZodCheckUpperCaseDef, $ZodCheckIncludesDef, $ZodCheckStartsWithDef, $ZodCheckEndsWithDef, $ZodCheckPropertyDef, $ZodCheckMimeTypeDef, $ZodCheckOverwriteDef } from 'zod/v4/core';
3
+ import { SomeType, $InferUnionInput, $ZodType, $ZodCheckLessThanDef, $ZodCheckGreaterThanDef, $ZodCheckMultipleOfDef, $ZodCheckNumberFormatDef, $ZodCheckMaxSizeDef, $ZodCheckMinSizeDef, $ZodCheckSizeEqualsDef, $ZodCheckMaxLengthDef, $ZodCheckMinLengthDef, $ZodCheckLengthEqualsDef, $ZodCheckStringFormatDef, $ZodCheckRegexDef, $ZodCheckIncludesDef, $ZodCheckStartsWithDef, $ZodCheckEndsWithDef, $ZodCheckMimeTypeDef, $ZodCheckOverwriteDef } from 'zod/v4/core';
4
4
 
5
5
  /**
6
6
  * Simplifies complex TypeScript types for better IDE hover tooltips and error messages.
@@ -365,6 +365,11 @@ type NameAndDiscriminatorProps<TSchema extends z$1.ZodType, TDiscriminatorKey ex
365
365
  */
366
366
  type FieldSelectorProps<TSchema extends z$1.ZodType, TDiscriminatorKey extends DiscriminatorKey<TSchema> = never, TDiscriminatorValue extends DiscriminatorValue<TSchema, TDiscriminatorKey> = never, TFilterType = unknown, TStrict extends boolean = true> = SchemaProps<TSchema> & NameAndDiscriminatorProps<TSchema, TDiscriminatorKey, TDiscriminatorValue, TFilterType, TStrict>;
367
367
 
368
+ /**
369
+ * Type-safe helper to iterate over ZodObject shape entries.
370
+ * @internal
371
+ */
372
+ declare function getShapeEntries(schema: z.ZodObject): Array<[string, z.ZodType | undefined]>;
368
373
  /**
369
374
  * Extracts the default value from a Zod field, recursively unwrapping optional, nullable, and union layers.
370
375
  *
@@ -650,19 +655,45 @@ type ExtractZodUnionMember<TSchema extends z$1.ZodUnion | z$1.ZodDiscriminatedUn
650
655
  * @see {@link ExtractZodUnionMember} for the type-level extraction logic
651
656
  * @since 0.6.0
652
657
  */
653
- declare const extractDiscriminatedSchema: <TSchema extends z$1.ZodType, TDiscriminatorKey extends DiscriminatorKey<TSchema>, TDiscriminatorValue extends DiscriminatorValue<TSchema, TDiscriminatorKey>, ReturnType extends TSchema extends z$1.ZodDiscriminatedUnion ? ExtractZodUnionMember<TSchema, TDiscriminatorKey, TDiscriminatorValue> : never>({ schema, discriminator, }: SchemaAndDiscriminatorProps<TSchema, TDiscriminatorKey, TDiscriminatorValue>) => ReturnType | undefined;
658
+ declare const extractDiscriminatedSchema: <TSchema extends z$1.ZodType, TDiscriminatorKey extends DiscriminatorKey<TSchema>, TDiscriminatorValue extends DiscriminatorValue<TSchema, TDiscriminatorKey>, TUnwrapped extends z$1.ZodType = UnwrapZodType<TSchema> extends z$1.ZodType ? UnwrapZodType<TSchema> : TSchema, ReturnType extends TUnwrapped extends z$1.ZodDiscriminatedUnion ? ExtractZodUnionMember<TUnwrapped, Extract<TDiscriminatorKey, DiscriminatorKey<TUnwrapped>>, Extract<TDiscriminatorValue, DiscriminatorValue<TUnwrapped, Extract<TDiscriminatorKey, DiscriminatorKey<TUnwrapped>>>>> : undefined = TUnwrapped extends z$1.ZodDiscriminatedUnion ? ExtractZodUnionMember<TUnwrapped, Extract<TDiscriminatorKey, DiscriminatorKey<TUnwrapped>>, Extract<TDiscriminatorValue, DiscriminatorValue<TUnwrapped, Extract<TDiscriminatorKey, DiscriminatorKey<TUnwrapped>>>>> : undefined>({ schema, discriminator, }: SchemaAndDiscriminatorProps<TSchema, TDiscriminatorKey, TDiscriminatorValue>) => ReturnType;
654
659
 
655
660
  type Split<S extends string> = S extends `${infer Head}.${infer Tail}` ? [Head, ...Split<Tail>] : [S];
656
661
  type IsNumeric<S extends string> = S extends `${number}` ? true : false;
657
- type Unwrap<T> = T extends z$1.ZodOptional<infer U> ? Unwrap<U> : T extends z$1.ZodNullable<infer U> ? Unwrap<U> : T extends z$1.ZodDefault<infer U> ? Unwrap<U> : T;
662
+ type Unwrap<T> = T extends z$1.ZodOptional<infer U> ? Unwrap<U> : T extends z$1.ZodNullable<infer U> ? Unwrap<U> : T extends z$1.ZodDefault<infer U> ? Unwrap<U> : T extends z$1.ZodPipe<infer In, z$1.ZodType> ? Unwrap<In> : T;
658
663
  type NavigateZod<T, Path extends string[]> = Path extends [
659
664
  infer First extends string,
660
665
  ...infer Rest extends string[]
661
666
  ] ? Unwrap<T> extends z$1.ZodObject<infer Shape> ? First extends keyof Shape ? Rest extends [] ? Shape[First] : NavigateZod<Shape[First], Rest> : never : Unwrap<T> extends z$1.ZodArray<infer Element> ? IsNumeric<First> extends true ? Rest extends [] ? Element : NavigateZod<Element, Rest> : never : never : T;
662
667
  type ExtractZodByPath<Schema, Path extends string> = NavigateZod<Schema, Split<Path>>;
668
+ /**
669
+ * Extract field from a discriminated union variant.
670
+ * First extracts the variant using ExtractZodUnionMember, then navigates through it.
671
+ * @internal
672
+ */
673
+ type ExtractFromDiscriminatedUnion<TSchema extends z$1.ZodType, TName extends string, TDiscriminatorKey extends DiscriminatorKey<TSchema>, TDiscriminatorValue extends DiscriminatorValue<TSchema, TDiscriminatorKey>, TUnwrapped extends z$1.ZodType = UnwrapZodType<TSchema> extends z$1.ZodType ? UnwrapZodType<TSchema> : TSchema, TVariant = TUnwrapped extends z$1.ZodDiscriminatedUnion ? ExtractZodUnionMember<TUnwrapped, Extract<TDiscriminatorKey, DiscriminatorKey<TUnwrapped>>, Extract<TDiscriminatorValue, DiscriminatorValue<TUnwrapped, Extract<TDiscriminatorKey, DiscriminatorKey<TUnwrapped>>>>> : never> = TVariant extends z$1.ZodType ? ExtractZodByPath<TVariant, TName> : never;
674
+ /**
675
+ * Helper type to determine if field extraction should succeed.
676
+ * Returns true when:
677
+ * 1. For discriminated unions: discriminator is provided (trust the user)
678
+ * 2. For non-unions: the path resolves to a valid type (not never)
679
+ * @internal
680
+ */
681
+ type CanExtractField<TSchema extends z$1.ZodType, TName extends string, TDiscriminatorKey extends DiscriminatorKey<TSchema>> = IsDiscriminatedUnion<TSchema> extends true ? [TDiscriminatorKey] extends [never] ? false : true : [
682
+ ExtractZodByPath<TSchema, TName>
683
+ ] extends [never] ? false : true;
684
+ /**
685
+ * Conditional return type for extractFieldFromSchema.
686
+ * For discriminated unions: extracts variant first, then navigates.
687
+ * For non-unions: navigates directly.
688
+ * @internal
689
+ */
690
+ type ExtractFieldResult<TSchema extends z$1.ZodType, TName extends string, TDiscriminatorKey extends DiscriminatorKey<TSchema>, TDiscriminatorValue extends DiscriminatorValue<TSchema, TDiscriminatorKey> = DiscriminatorValue<TSchema, TDiscriminatorKey>> = CanExtractField<TSchema, TName, TDiscriminatorKey> extends true ? IsDiscriminatedUnion<TSchema> extends true ? [
691
+ ExtractFromDiscriminatedUnion<TSchema, TName, TDiscriminatorKey, TDiscriminatorValue>
692
+ ] extends [never] ? z$1.ZodType : ExtractFromDiscriminatedUnion<TSchema, TName, TDiscriminatorKey, TDiscriminatorValue> & z$1.ZodType : // For non-unions: navigate directly
693
+ ExtractZodByPath<TSchema, TName> & z$1.ZodType : (ExtractZodByPath<TSchema, TName> & z$1.ZodType) | undefined;
663
694
  declare function extractFieldFromSchema<TSchema extends z$1.ZodType, TDiscriminatorKey extends DiscriminatorKey<TSchema> = never, TDiscriminatorValue extends DiscriminatorValue<TSchema, TDiscriminatorKey> = never, TFilterType = unknown, TStrict extends boolean = true, TName extends string = string>(params: FieldSelectorProps<TSchema, TDiscriminatorKey, TDiscriminatorValue, TFilterType, TStrict> & {
664
695
  name: TName;
665
- }): (ExtractZodByPath<TSchema, TName> & z$1.ZodType) | undefined;
696
+ }): ExtractFieldResult<TSchema, TName, TDiscriminatorKey, TDiscriminatorValue>;
666
697
  /**
667
698
  * Extends a Zod field with a transformation while preserving its metadata.
668
699
  *
@@ -684,6 +715,115 @@ declare function extractFieldFromSchema<TSchema extends z$1.ZodType, TDiscrimina
684
715
  */
685
716
  declare function extendWithMeta<T extends z$1.ZodType, R extends z$1.ZodType>(field: T, transform: (f: T) => R): R;
686
717
 
718
+ /**
719
+ * Extracts the value of a specific meta key from a Zod field, recursively unwrapping
720
+ * optional, nullable, default, transform, and union layers.
721
+ *
722
+ * For `ZodObject` fields: if the object's own meta contains the target key, returns that
723
+ * value directly (stops recursion). If not, recurses into shape children and returns
724
+ * a nested record of meta values.
725
+ *
726
+ * @param field - The Zod field to extract meta from
727
+ * @param metaKey - The meta property key to extract
728
+ * @returns The meta value if found, undefined otherwise
729
+ *
730
+ * @example
731
+ * ```typescript
732
+ * const field = z.string().meta({ label: 'Name' });
733
+ * extractMeta(field, 'label'); // 'Name'
734
+ * ```
735
+ *
736
+ * @example
737
+ * ```typescript
738
+ * const field = z.string().meta({ label: 'Name' }).optional();
739
+ * extractMeta(field, 'label'); // 'Name' (unwraps optional)
740
+ * ```
741
+ *
742
+ * @see {@link getSchemaMeta} for extracting meta from entire schemas
743
+ * @since 0.3.0
744
+ */
745
+ declare function extractMeta(field: z.ZodType, metaKey: string): unknown;
746
+ /**
747
+ * Extracts the value of a specific meta key from all fields in a Zod schema.
748
+ *
749
+ * Returns a nested record where each key maps to the meta value for that field.
750
+ * Fields without the specified meta key are omitted.
751
+ *
752
+ * For `ZodObject` fields: if the object has the target meta key in its own meta,
753
+ * returns that value directly. Otherwise, recurses into shape children.
754
+ *
755
+ * Supports discriminated unions via the `discriminator` parameter.
756
+ *
757
+ * @param params - Schema and optional discriminator configuration
758
+ * @param metaKey - The meta property key to extract
759
+ * @returns Record mapping field names to their meta values
760
+ *
761
+ * To get typed meta keys with autocomplete, augment Zod's `GlobalMeta` interface:
762
+ *
763
+ * ```typescript
764
+ * // types/zod.ts
765
+ * import * as z from 'zod';
766
+ *
767
+ * declare module 'zod' {
768
+ * interface GlobalMeta {
769
+ * label: string; // static type for all schemas
770
+ * type: z.$output; // resolves to the schema's output type
771
+ * inputType: z.$input; // resolves to the schema's input type
772
+ * placeholder?: string;
773
+ * }
774
+ * }
775
+ * ```
776
+ *
777
+ * With `z.$output` / `z.$input`, Zod automatically types `.meta()` values
778
+ * based on each schema's inferred type:
779
+ *
780
+ * ```typescript
781
+ * z.string().meta({ type: 'hello' }) // ✅ type is string
782
+ * z.string().meta({ type: 42 }) // ❌ TypeScript error — expects string
783
+ * z.number().meta({ type: 42 }) // ✅ type is number
784
+ * ```
785
+ *
786
+ * @example
787
+ * ```typescript
788
+ * const schema = z.object({
789
+ * name: z.string().meta({ label: 'Name' }),
790
+ * age: z.number().meta({ label: 'Age' }),
791
+ * });
792
+ * getSchemaMeta({ schema }, 'label');
793
+ * // { name: 'Name', age: 'Age' }
794
+ * ```
795
+ *
796
+ * @see {@link extractMeta} for extracting meta from individual fields
797
+ * @since 0.3.0
798
+ */
799
+ declare function getSchemaMeta<TSchema extends z.ZodType, TDiscriminatorKey extends DiscriminatorKey<TSchema>, TDiscriminatorValue extends DiscriminatorValue<TSchema, TDiscriminatorKey>>(params: SchemaAndDiscriminatorProps<TSchema, TDiscriminatorKey, TDiscriminatorValue>, metaKey: string): Simplify<Partial<z.input<TSchema>>>;
800
+ /**
801
+ * Combines schema defaults and meta values into a single result.
802
+ * Meta values take precedence over defaults where both exist.
803
+ * For nested objects, performs a deep merge so that fields from both
804
+ * sources are preserved at every level.
805
+ *
806
+ * @param params - Schema and optional discriminator configuration
807
+ * @param metaKey - The meta property key to extract
808
+ * @returns Deep-merged record of defaults and meta values (meta wins on conflict)
809
+ *
810
+ * @example
811
+ * ```typescript
812
+ * const schema = z.object({
813
+ * name: z.string().meta({ label: 'Name' }).default('hello'),
814
+ * age: z.number().meta({ label: 'Age' }),
815
+ * bio: z.string().default(''),
816
+ * });
817
+ * getMergedSchemaDefaults({ schema }, 'label');
818
+ * // { name: 'Name', age: 'Age', bio: '' }
819
+ * ```
820
+ *
821
+ * @see {@link getSchemaDefaults} for extracting only defaults
822
+ * @see {@link getSchemaMeta} for extracting only meta
823
+ * @since 0.5.0
824
+ */
825
+ declare function getMergedSchemaDefaults<TSchema extends z.ZodType, TDiscriminatorKey extends DiscriminatorKey<TSchema>, TDiscriminatorValue extends DiscriminatorValue<TSchema, TDiscriminatorKey>>(params: SchemaAndDiscriminatorProps<TSchema, TDiscriminatorKey, TDiscriminatorValue>, metaKey: string): Simplify<Partial<z.input<TSchema>>>;
826
+
687
827
  /**
688
828
  * Type representing a Zod type that has an unwrap method
689
829
  */
@@ -710,7 +850,7 @@ type Unwrappable = {
710
850
  *
711
851
  * @since 0.1.0
712
852
  */
713
- declare function canUnwrap(field: z$1.ZodTypeAny): field is z$1.ZodTypeAny & Unwrappable;
853
+ declare function canUnwrap(field: z$1.ZodType | $ZodType): field is (z$1.ZodType | $ZodType) & Unwrappable;
714
854
  /**
715
855
  * Type guard that checks if a Zod field is a ZodPipe with a ZodType input.
716
856
  *
@@ -719,7 +859,7 @@ declare function canUnwrap(field: z$1.ZodTypeAny): field is z$1.ZodTypeAny & Unw
719
859
  * @param field - The Zod field to check
720
860
  * @returns True if field is a ZodPipe with a ZodType input
721
861
  */
722
- declare function isPipeWithZodInput(field: z$1.ZodTypeAny): field is z$1.ZodPipe<z$1.ZodType, z$1.ZodTypeAny>;
862
+ declare function isPipeWithZodInput(field: z$1.ZodType | $ZodType): field is z$1.ZodPipe<z$1.ZodType, z$1.ZodTypeAny>;
723
863
  /**
724
864
  * Attempts to strip nullish types from a union and return the single remaining type.
725
865
  *
@@ -816,7 +956,7 @@ declare function tryStripNullishOnly(field: z$1.ZodTypeAny): z$1.ZodType | false
816
956
  * @see {@link tryStripNullishOnly} for union nullish stripping logic
817
957
  * @since 0.1.0
818
958
  */
819
- declare const getPrimitiveType: <T extends z$1.ZodType>(field: T) => z$1.ZodTypeAny;
959
+ declare const getPrimitiveType: <T extends z$1.ZodType>(field: T) => z$1.ZodType;
820
960
  type StripZodDefault<T> = T extends z$1.ZodDefault<infer Inner> ? StripZodDefault<Inner> : T extends z$1.ZodOptional<infer Inner> ? z$1.ZodOptional<StripZodDefault<Inner>> : T extends z$1.ZodNullable<infer Inner> ? z$1.ZodNullable<StripZodDefault<Inner>> : T;
821
961
  /**
822
962
  * Removes default values from a Zod field while preserving other wrapper types.
@@ -948,7 +1088,7 @@ declare const requiresValidInput: <T extends z$1.ZodType>(field: T) => boolean;
948
1088
  *
949
1089
  * @since 0.4.0
950
1090
  */
951
- type ZodUnionCheck = $ZodCheckLessThanDef | $ZodCheckGreaterThanDef | $ZodCheckMultipleOfDef | $ZodCheckNumberFormatDef | $ZodCheckBigIntFormatDef | $ZodCheckMaxSizeDef | $ZodCheckMinSizeDef | $ZodCheckSizeEqualsDef | $ZodCheckMaxLengthDef | $ZodCheckMinLengthDef | $ZodCheckLengthEqualsDef | $ZodCheckStringFormatDef | $ZodCheckRegexDef | $ZodCheckLowerCaseDef | $ZodCheckUpperCaseDef | $ZodCheckIncludesDef | $ZodCheckStartsWithDef | $ZodCheckEndsWithDef | $ZodCheckPropertyDef | $ZodCheckMimeTypeDef | $ZodCheckOverwriteDef;
1091
+ type ZodUnionCheck = $ZodCheckLessThanDef | $ZodCheckGreaterThanDef | $ZodCheckMultipleOfDef | $ZodCheckNumberFormatDef | $ZodCheckMaxSizeDef | $ZodCheckMinSizeDef | $ZodCheckSizeEqualsDef | $ZodCheckMaxLengthDef | $ZodCheckMinLengthDef | $ZodCheckLengthEqualsDef | $ZodCheckStringFormatDef | $ZodCheckRegexDef | $ZodCheckIncludesDef | $ZodCheckStartsWithDef | $ZodCheckEndsWithDef | $ZodCheckMimeTypeDef | $ZodCheckOverwriteDef;
952
1092
  /**
953
1093
  * Extracts all validation check definitions from a Zod schema field.
954
1094
  *
@@ -1024,6 +1164,7 @@ type ZodUnionCheck = $ZodCheckLessThanDef | $ZodCheckGreaterThanDef | $ZodCheckM
1024
1164
  * @see {@link ZodUnionCheck} for all supported check types
1025
1165
  * @since 0.4.0
1026
1166
  */
1027
- declare function getFieldChecks<T extends z$1.ZodTypeAny>(field: T): Array<ZodUnionCheck>;
1167
+ declare function getFieldChecks<T extends z$1.ZodType | $ZodType>(field: T): Array<ZodUnionCheck>;
1168
+ declare function extractCheck(check: z$1.core.$ZodCheck<never>): ZodUnionCheck[];
1028
1169
 
1029
- export { type CommonFields, type DiscriminatedInput, type DiscriminatorKey, type DiscriminatorProps, type DiscriminatorValue, type ExtractZodByPath, type FieldSelectorProps, type FileList, type IsDiscriminatedUnion, type NameAndDiscriminatorProps, type NameProps, type PathImpl, type PathInternal, type Paths, type SchemaAndDiscriminatorProps, type SchemaProps, type Simplify, type UnwrapZodType, type ValidPaths, type ZodUnionCheck, canUnwrap, extendWithMeta, extractDefaultValue, extractDiscriminatedSchema, extractFieldFromSchema, getFieldChecks, getPrimitiveType, getSchemaDefaults, isPipeWithZodInput, removeDefault, requiresValidInput, tryStripNullishOnly };
1170
+ export { type CommonFields, type DiscriminatedInput, type DiscriminatorKey, type DiscriminatorProps, type DiscriminatorValue, type ExtractZodByPath, type ExtractZodUnionMember, type FieldSelectorProps, type FileList, type IsDiscriminatedUnion, type NameAndDiscriminatorProps, type NameProps, type PathImpl, type PathInternal, type Paths, type SchemaAndDiscriminatorProps, type SchemaProps, type Simplify, type UnwrapZodType, type ValidPaths, type ZodUnionCheck, canUnwrap, extendWithMeta, extractCheck, extractDefaultValue, extractDiscriminatedSchema, extractFieldFromSchema, extractMeta, getFieldChecks, getMergedSchemaDefaults, getPrimitiveType, getSchemaDefaults, getSchemaMeta, getShapeEntries, isPipeWithZodInput, removeDefault, requiresValidInput, tryStripNullishOnly };