Skip to content

Commit 86a9c8b

Browse files
authored
Fix the type of examples prop for dateIn and dateOut params (#2903)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - Bug Fixes - Corrected typing of the examples parameter for dateIn/dateOut, improving TypeScript accuracy and IDE hints. - Refactor - Introduced dedicated parameter types for dateIn/dateOut to clarify API typings without changing runtime behavior. - Documentation - Updated changelog punctuation. - Documented the corrected examples types for dateIn/dateOut. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent a40af85 commit 86a9c8b

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
### v25.3.1
66

7-
- Small optimization for running diagnostics (non-production mode).
7+
- Small optimization for running diagnostics (non-production mode);
8+
- Fixed the type of the `examples` property for `ez.dateIn()` and `ez.dateOut()` arguments.
89

910
### v25.3.0
1011

express-zod-api/src/date-in-schema.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import { z } from "zod";
22

33
export const ezDateInBrand = Symbol("DateIn");
44

5-
export const dateIn = ({
6-
examples,
7-
...rest
8-
}: Parameters<z.ZodString["meta"]>[0] = {}) => {
5+
export interface DateInParams
6+
extends Omit<Parameters<z.ZodString["meta"]>[0], "examples"> {
7+
examples?: string[];
8+
}
9+
10+
export const dateIn = ({ examples, ...rest }: DateInParams = {}) => {
911
const schema = z.union([
1012
z.iso.date(),
1113
z.iso.datetime(),

express-zod-api/src/date-out-schema.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import { z } from "zod";
22

33
export const ezDateOutBrand = Symbol("DateOut");
44

5-
export const dateOut = (meta: Parameters<z.ZodString["meta"]>[0] = {}) =>
5+
export interface DateOutParams
6+
extends Omit<Parameters<z.ZodString["meta"]>[0], "examples"> {
7+
examples?: string[];
8+
}
9+
10+
export const dateOut = (meta: DateOutParams = {}) =>
611
z
712
.date()
813
.transform((date) => date.toISOString())

0 commit comments

Comments
 (0)