-
-
Notifications
You must be signed in to change notification settings - Fork 169
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
feat: add intersection schema #117
Conversation
✅ Deploy Preview for valibot ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Thank you for your contribution! The next few days I have to focus on my bachelor thesis. As soon as I find time, I'll get back to you. |
If there is still interest in this PR, please check this comment beforehand and give me feedback on it. |
return value; | ||
}) as IntersectionOutput<TIntersectionOptions>, | ||
} | ||
: getIssues( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my case validation errors from intersected objects didn't bubble up, and I had to do this:
return !issues && output
? {
...
}
: issues?.length
? { issues }
: getIssues(info, 'type', 'intersection', error || 'Invalid type', input, issues)
Please check this, and if valid this applies to intersectionAsync, too
// If there are issues, set output and break loop | ||
if (result.issues) { | ||
issues = result.issues; | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my case validation errors from intersected objects didn't bubble up, and I had to do this:
if (result.issues) {
issues = result.issues
while (issues?.length) {
issues = (issues => issues.length ? issues as Issues : undefined)(issues.flatMap(i => i.issues ?? []))
?? issues
break
}
break
} else ...
Please check this, and if valid this applies to intersectionAsync, too
I will probably review this PR in the next few days. |
@alonidiom Please check out my fork of your PR! Karakatiza666@fd1830f |
I am currently working on this PR. I'll check your code in a moment. |
I'm not done yet, but I welcome feedback or questions now before I finalize it. |
Apart from that, I also revised the code that merges two or more outputs so that it should now work with every schema. |
Will check if I encounter issues with new code tomorrow, wasn't able to try earlier |
I have finalized the implementation. Feel free to test out the changes and let me know if anything can be improved. |
I plan to merge this PR today or tomorrow. |
Fixes #113 (including the specific case mentioned)