File tree Expand file tree Collapse file tree 4 files changed +3
-47
lines changed Expand file tree Collapse file tree 4 files changed +3
-47
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @zod/zod" ,
3- "version" : " 4.1.0 " ,
3+ "version" : " 4.1.1 " ,
44 "exports" : {
55 "./package.json" : " ./package.json" ,
66 "." : " ./src/index.ts" ,
Original file line number Diff line number Diff line change 11{
22 "name" : " zod" ,
3- "version" : " 4.1.0 " ,
3+ "version" : " 4.1.1 " ,
44 "type" : " module" ,
55 "license" : " MIT" ,
66 "author" : " Colin McDonnell <zod@colinhacks.com>" ,
Original file line number Diff line number Diff line change 11export const version = {
22 major : 4 ,
33 minor : 1 ,
4- patch : 0 as number ,
4+ patch : 1 as number ,
55} as const ;
Original file line number Diff line number Diff line change 11import * as z from "zod" ;
22
33z ;
4-
5- const stringToDate = z . codec (
6- z . iso . datetime ( ) , // input schema: ISO date string
7- z . date ( ) , // output schema: Date object
8- {
9- decode : ( isoString ) => new Date ( isoString ) , // ISO string → Date
10- encode : ( date ) => date . toISOString ( ) , // Date → ISO string
11- }
12- ) ;
13-
14- stringToDate . decode ( "2024-01-15T10:30:00.000Z" ) ;
15- // => Date
16-
17- stringToDate . encode ( new Date ( ) )
18- // => string
19-
20-
21- stringToDate . decode ( 1234 ) ;
22- // ^ Argument of type 'number' is not assignable
23- // to parameter of type 'string'.ts(2345)
24-
25- stringToDate . encode ( 1234 ) ;
26- // ^ Argument of type 'number' is not assignable
27- // to parameter of type 'Date'.ts(2345)
28-
29-
30-
31- including:
32-
33- ✅ stringToNumber
34- ✅ stringToInt
35- ✅ stringToBigInt
36- ✅ numberToBigInt
37- ✅ isoDatetimeToDate
38- ✅ epochSecondsToDate
39- ✅ epochMillisToDate
40- ✅ jsonCodec
41- ✅ utf8ToBytes
42- ✅ bytesToUtf8
43- ✅ base64ToBytes
44- ✅ base64urlToBytes
45- ✅ hexToBytes
46- ✅ stringToURL
47- ✅ uriComponent
You can’t perform that action at this time.
0 commit comments