File tree Expand file tree Collapse file tree 3 files changed +8
-4
lines changed
Expand file tree Collapse file tree 3 files changed +8
-4
lines changed Original file line number Diff line number Diff line change 44** /* .d.ts
55** /* .d.mts
66** /* .d.cts
7+ ** /package.json
Original file line number Diff line number Diff line change @@ -920,6 +920,8 @@ test("CIDR v6 validation", () => {
920920 expect ( cidrV6 . safeParse ( "not a cidr" ) . success ) . toBe ( false ) ; // Invalid format
921921 expect ( cidrV6 . safeParse ( "192.168.0.0/24" ) . success ) . toBe ( false ) ; // IPv4 CIDR in v6 validation
922922 expect ( cidrV6 . safeParse ( "2001:0db8:85a3::/64/whatever-after" ) . success ) . toBe ( false ) ;
923+ expect ( cidrV6 . safeParse ( "22d9:f4a8:6a90:f3bf:dcaa:2beb:5fba:0000/112" ) . success ) . toBe ( true ) ;
924+ expect ( cidrV6 . safeParse ( "22d9:f4a8:6a90:f3bf:dcaa:2beb:5fba:0000/112/268" ) . success ) . toBe ( false ) ;
923925} ) ;
924926
925927test ( "E.164 validation" , ( ) => {
Original file line number Diff line number Diff line change @@ -830,10 +830,11 @@ export const $ZodCIDRv6: core.$constructor<$ZodCIDRv6> = /*@__PURE__*/ core.$con
830830 $ZodStringFormat . init ( inst , def ) ;
831831
832832 inst . _zod . check = ( payload ) => {
833- const segments = payload . value . split ( "/" ) ;
834- const [ address , prefix ] = segments ;
833+ const parts = payload . value . split ( "/" ) ;
835834 try {
836- if ( segments . length !== 2 ) throw new Error ( ) ;
835+ if ( parts . length !== 2 ) throw new Error ( ) ;
836+ const [ address , prefix ] = parts ;
837+ if ( ! prefix ) throw new Error ( ) ;
837838 const prefixNum = Number ( prefix ) ;
838839 if ( `${ prefixNum } ` !== prefix ) throw new Error ( ) ;
839840 if ( prefixNum < 0 || prefixNum > 128 ) throw new Error ( ) ;
@@ -1763,7 +1764,7 @@ export interface $ZodObject<
17631764function normalizeDef ( def : $ZodObjectDef ) {
17641765 const keys = Object . keys ( def . shape ) ;
17651766 for ( const k of keys ) {
1766- if ( ! def . shape [ k ] . _zod . traits . has ( "$ZodType" ) ) {
1767+ if ( ! def . shape ?. [ k ] ? ._zod ? .traits ? .has ( "$ZodType" ) ) {
17671768 throw new Error ( `Invalid element at key "${ k } ": expected a Zod schema` ) ;
17681769 }
17691770 }
You can’t perform that action at this time.
0 commit comments