Skip to content

Conversation

@KubaJastrz
Copy link

@KubaJastrz KubaJastrz commented Apr 10, 2025

Fixes #1147

@vercel
Copy link

vercel bot commented Apr 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
valibot ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 12, 2025 8:05am

@KubaJastrz KubaJastrz changed the title fix(intersect): do not fail on looseObject with pipe' fix(intersect): do not fail on looseObject with pipe Apr 10, 2025
@KubaJastrz
Copy link
Author

KubaJastrz commented Apr 10, 2025

I'm actually not sure what is the best course of action here.

I originally wanted to change the schema from looseObject to object but this doesn't seem possible, because we'd have to create a new schema and it would require importing object into intersect.
https://github.com/fabian-hiller/valibot/blob/bc8463c0c5344bc3e21757715b90b67a9533af63/library/src/schemas/intersect/intersect.ts#L108

The other option was to only replace [~run] but it kind of has the same problem.

I'm thinking about stripping unknown entries from value, in case the schema type is looseObject, but how would you bring those keys back? What if one of these keys is actually transformed by another schema?
https://github.com/fabian-hiller/valibot/blob/bc8463c0c5344bc3e21757715b90b67a9533af63/library/src/schemas/intersect/intersect.ts#L134-L138

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problem with intersecting looseObjects with optional pipes

1 participant