@hy_ong/zod-kit 0.2.5 → 0.2.6

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.
@@ -10,7 +10,7 @@ import { L as Locale } from '../config-CABSSvAp.cjs';
10
10
  * Avoids z.preprocess() to preserve z.input types for React Hook Form compatibility.
11
11
  *
12
12
  * @author Ong Hoe Yuan
13
- * @version 0.2.5
13
+ * @version 0.2.6
14
14
  */
15
15
 
16
16
  /**
@@ -62,7 +62,7 @@ type ManyOfOptions<IsRequired extends boolean = true, V extends readonly (string
62
62
  * @template IsRequired - Whether the field is required
63
63
  * @template V - The tuple type of allowed values
64
64
  */
65
- type ManyOfSchema<IsRequired extends boolean, V extends readonly (string | number)[]> = IsRequired extends true ? ZodType<V[number][], V[number][] | "" | null | undefined> : ZodType<V[number][] | null, V[number][] | "" | null | undefined>;
65
+ type ManyOfSchema<IsRequired extends boolean, V extends readonly (string | number)[]> = IsRequired extends true ? ZodType<V[number][], V[number][]> : ZodType<V[number][] | null, V[number][] | "" | null | undefined>;
66
66
  /**
67
67
  * Creates a Zod schema for multi-select validation that restricts values to a predefined set
68
68
  *
@@ -10,7 +10,7 @@ import { L as Locale } from '../config-CABSSvAp.js';
10
10
  * Avoids z.preprocess() to preserve z.input types for React Hook Form compatibility.
11
11
  *
12
12
  * @author Ong Hoe Yuan
13
- * @version 0.2.5
13
+ * @version 0.2.6
14
14
  */
15
15
 
16
16
  /**
@@ -62,7 +62,7 @@ type ManyOfOptions<IsRequired extends boolean = true, V extends readonly (string
62
62
  * @template IsRequired - Whether the field is required
63
63
  * @template V - The tuple type of allowed values
64
64
  */
65
- type ManyOfSchema<IsRequired extends boolean, V extends readonly (string | number)[]> = IsRequired extends true ? ZodType<V[number][], V[number][] | "" | null | undefined> : ZodType<V[number][] | null, V[number][] | "" | null | undefined>;
65
+ type ManyOfSchema<IsRequired extends boolean, V extends readonly (string | number)[]> = IsRequired extends true ? ZodType<V[number][], V[number][]> : ZodType<V[number][] | null, V[number][] | "" | null | undefined>;
66
66
  /**
67
67
  * Creates a Zod schema for multi-select validation that restricts values to a predefined set
68
68
  *
@@ -7,11 +7,11 @@ import { L as Locale } from '../config-CABSSvAp.cjs';
7
7
  * Provides single-select validation that restricts input to a predefined set of allowed values,
8
8
  * with support for case-insensitive matching, default values, and transformation.
9
9
  *
10
- * Uses z.enum() internally to preserve literal type inference for both z.input and z.output,
11
- * making it compatible with React Hook Form resolvers and other type-aware form libraries.
10
+ * When required=true, z.input is narrowed to V[number] (no empty/null/undefined),
11
+ * making it fully compatible with React Hook Form resolvers and type-aware form libraries.
12
12
  *
13
13
  * @author Ong Hoe Yuan
14
- * @version 0.2.5
14
+ * @version 0.2.6
15
15
  */
16
16
 
17
17
  /**
@@ -51,12 +51,12 @@ type OneOfOptions<IsRequired extends boolean = true, V extends readonly (string
51
51
  * @template IsRequired - Whether the field is required
52
52
  * @template V - The tuple type of allowed values
53
53
  */
54
- type OneOfSchema<IsRequired extends boolean, V extends readonly (string | number)[]> = IsRequired extends true ? ZodType<V[number], V[number] | "" | null | undefined> : ZodType<V[number] | null, V[number] | "" | null | undefined>;
54
+ type OneOfSchema<IsRequired extends boolean, V extends readonly (string | number)[]> = IsRequired extends true ? ZodType<V[number], V[number]> : ZodType<V[number] | null, V[number] | "" | null | undefined>;
55
55
  /**
56
56
  * Creates a Zod schema for single-select validation that restricts values to a predefined set
57
57
  *
58
- * Uses z.enum() internally to preserve both z.input and z.output literal types,
59
- * ensuring compatibility with React Hook Form and other type-aware form libraries.
58
+ * When required=true, z.input is narrowed to V[number] only (no empty/null/undefined),
59
+ * ensuring full compatibility with React Hook Form and other type-aware form libraries.
60
60
  *
61
61
  * @template IsRequired - Whether the field is required (affects return type)
62
62
  * @template V - The tuple type of allowed values (inferred via const type parameter)
@@ -7,11 +7,11 @@ import { L as Locale } from '../config-CABSSvAp.js';
7
7
  * Provides single-select validation that restricts input to a predefined set of allowed values,
8
8
  * with support for case-insensitive matching, default values, and transformation.
9
9
  *
10
- * Uses z.enum() internally to preserve literal type inference for both z.input and z.output,
11
- * making it compatible with React Hook Form resolvers and other type-aware form libraries.
10
+ * When required=true, z.input is narrowed to V[number] (no empty/null/undefined),
11
+ * making it fully compatible with React Hook Form resolvers and type-aware form libraries.
12
12
  *
13
13
  * @author Ong Hoe Yuan
14
- * @version 0.2.5
14
+ * @version 0.2.6
15
15
  */
16
16
 
17
17
  /**
@@ -51,12 +51,12 @@ type OneOfOptions<IsRequired extends boolean = true, V extends readonly (string
51
51
  * @template IsRequired - Whether the field is required
52
52
  * @template V - The tuple type of allowed values
53
53
  */
54
- type OneOfSchema<IsRequired extends boolean, V extends readonly (string | number)[]> = IsRequired extends true ? ZodType<V[number], V[number] | "" | null | undefined> : ZodType<V[number] | null, V[number] | "" | null | undefined>;
54
+ type OneOfSchema<IsRequired extends boolean, V extends readonly (string | number)[]> = IsRequired extends true ? ZodType<V[number], V[number]> : ZodType<V[number] | null, V[number] | "" | null | undefined>;
55
55
  /**
56
56
  * Creates a Zod schema for single-select validation that restricts values to a predefined set
57
57
  *
58
- * Uses z.enum() internally to preserve both z.input and z.output literal types,
59
- * ensuring compatibility with React Hook Form and other type-aware form libraries.
58
+ * When required=true, z.input is narrowed to V[number] only (no empty/null/undefined),
59
+ * ensuring full compatibility with React Hook Form and other type-aware form libraries.
60
60
  *
61
61
  * @template IsRequired - Whether the field is required (affects return type)
62
62
  * @template V - The tuple type of allowed values (inferred via const type parameter)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hy_ong/zod-kit",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "A comprehensive TypeScript library providing pre-built Zod validation schemas with full internationalization support for common data types and Taiwan-specific formats",
5
5
  "keywords": [
6
6
  "zod",
@@ -7,7 +7,7 @@
7
7
  * Avoids z.preprocess() to preserve z.input types for React Hook Form compatibility.
8
8
  *
9
9
  * @author Ong Hoe Yuan
10
- * @version 0.2.5
10
+ * @version 0.2.6
11
11
  */
12
12
 
13
13
  import { z, ZodType } from "zod"
@@ -66,7 +66,7 @@ export type ManyOfOptions<IsRequired extends boolean = true, V extends readonly
66
66
  * @template V - The tuple type of allowed values
67
67
  */
68
68
  export type ManyOfSchema<IsRequired extends boolean, V extends readonly (string | number)[]> = IsRequired extends true
69
- ? ZodType<V[number][], V[number][] | "" | null | undefined>
69
+ ? ZodType<V[number][], V[number][]>
70
70
  : ZodType<V[number][] | null, V[number][] | "" | null | undefined>
71
71
 
72
72
  /**
@@ -4,11 +4,11 @@
4
4
  * Provides single-select validation that restricts input to a predefined set of allowed values,
5
5
  * with support for case-insensitive matching, default values, and transformation.
6
6
  *
7
- * Uses z.enum() internally to preserve literal type inference for both z.input and z.output,
8
- * making it compatible with React Hook Form resolvers and other type-aware form libraries.
7
+ * When required=true, z.input is narrowed to V[number] (no empty/null/undefined),
8
+ * making it fully compatible with React Hook Form resolvers and type-aware form libraries.
9
9
  *
10
10
  * @author Ong Hoe Yuan
11
- * @version 0.2.5
11
+ * @version 0.2.6
12
12
  */
13
13
 
14
14
  import { z, ZodType } from "zod"
@@ -55,14 +55,14 @@ export type OneOfOptions<IsRequired extends boolean = true, V extends readonly (
55
55
  * @template V - The tuple type of allowed values
56
56
  */
57
57
  export type OneOfSchema<IsRequired extends boolean, V extends readonly (string | number)[]> = IsRequired extends true
58
- ? ZodType<V[number], V[number] | "" | null | undefined>
58
+ ? ZodType<V[number], V[number]>
59
59
  : ZodType<V[number] | null, V[number] | "" | null | undefined>
60
60
 
61
61
  /**
62
62
  * Creates a Zod schema for single-select validation that restricts values to a predefined set
63
63
  *
64
- * Uses z.enum() internally to preserve both z.input and z.output literal types,
65
- * ensuring compatibility with React Hook Form and other type-aware form libraries.
64
+ * When required=true, z.input is narrowed to V[number] only (no empty/null/undefined),
65
+ * ensuring full compatibility with React Hook Form and other type-aware form libraries.
66
66
  *
67
67
  * @template IsRequired - Whether the field is required (affects return type)
68
68
  * @template V - The tuple type of allowed values (inferred via const type parameter)