File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -249,23 +249,25 @@ exports[`Environment checks > Zod imperfections > circular object schema has no
249249}
250250` ;
251251
252- exports [` Environment checks > Zod imperfections > input examples of transformations 1` ] = `
252+ exports [` Environment checks > Zod imperfections > meta overrides, does not merge 1` ] = `
253253{
254- " examples" : [
255- 4 ,
256- ],
257- " type" : " string" ,
254+ " title" : " last" ,
258255}
259256` ;
260257
261- exports [` Environment checks > Zod imperfections > meta overrides, does not merge 1` ] = `
258+ exports [` Environment checks > Zod new features > input examples of transformations 1` ] = `
262259{
263- " title" : " last" ,
260+ " $schema" : " https://json-schema.org/draft-2020-12/schema" ,
261+ " examples" : [
262+ " test" ,
263+ ],
264+ " type" : " string" ,
264265}
265266` ;
266267
267- exports [` Environment checks > Zod imperfections > output examples of transformations 1` ] = `
268+ exports [` Environment checks > Zod new features > output examples of transformations 1` ] = `
268269{
270+ " $schema" : " https://json-schema.org/draft-2020-12/schema" ,
269271 " examples" : [
270272 4 ,
271273 ],
Original file line number Diff line number Diff line change @@ -125,6 +125,24 @@ describe("Environment checks", () => {
125125 expect ( boolSchema . isOptional ( ) ) . toBeTruthy ( ) ;
126126 expect ( boolSchema . isNullable ( ) ) . toBeTruthy ( ) ;
127127 } ) ;
128+
129+ /**
130+ * @link https://github.com/colinhacks/zod/issues/4274
131+ * @todo this fact can be used for switching to native examples
132+ * */
133+ test . each ( [ "input" , "output" ] as const ) (
134+ "%s examples of transformations" ,
135+ ( io ) => {
136+ const schema = z
137+ . string ( )
138+ . meta ( { examples : [ "test" ] } )
139+ . transform ( Number )
140+ . meta ( { examples : [ 4 ] } ) ;
141+ expect (
142+ z . toJSONSchema ( schema , { io, unrepresentable : "any" } ) ,
143+ ) . toMatchSnapshot ( ) ;
144+ } ,
145+ ) ;
128146 } ) ;
129147
130148 describe ( "Vitest error comparison" , ( ) => {
You can’t perform that action at this time.
0 commit comments