Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeepPartial Array length validation #2127

Closed
marcpaskell opened this issue Mar 2, 2023 · 4 comments
Closed

DeepPartial Array length validation #2127

marcpaskell opened this issue Mar 2, 2023 · 4 comments
Labels
bug-confirmed Bug report that is confirmed

Comments

@marcpaskell
Copy link

Hi! So just stumbled upon this, it would appear that something in 3.8 broke the way array().min() works with deepPartial()

If you check this codepen

https://codepen.io/pasco82/pen/GRXmJgV?editors=0011

with v 3.7.1

{
  "success": false,
  "error": {
    ....
  }
}

but with v 3.8.1

{
  "success": true,
  "data": {
    "clientContacts": []
  }
}

Is there a change in syntax i've missed somewhere?

thanks in advance 👍

@JacobWeisenburger
Copy link
Collaborator

Bug Confirmed:

const schema = z.object( { array: z.string().array().min( 42 ).optional() } )

// works as expected
console.log( schema.safeParse( {} ).success ) // true

// works as expected
console.log( schema.safeParse( { array: [] } ).success ) // false
const schema = z.object( { array: z.string().array().min( 42 ) } ).deepPartial()

// works as expected
console.log( schema.safeParse( {} ).success ) // true

// should be false, but is true
console.log( schema.safeParse( { array: [] } ).success ) // true

@JacobWeisenburger JacobWeisenburger added the bug-confirmed Bug report that is confirmed label Mar 3, 2023
@colinhacks
Copy link
Owner

Good catch @marcpaskell - that's a seriously old bug.

@marcpaskell
Copy link
Author

thanks all for jumping on this so quickly

@JacobWeisenburger
Copy link
Collaborator

JacobWeisenburger commented Mar 6, 2023

@colinhacks
this bug seems to be fixed, but now vscode is saying that deepPartial is deprecated. Is there something replacing it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-confirmed Bug report that is confirmed
Projects
None yet
Development

No branches or pull requests

3 participants