-
-
Notifications
You must be signed in to change notification settings - Fork 511
fix(form-core): handle string array indices in prefixSchemaToErrors #1689
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
base: main
Are you sure you want to change the base?
Conversation
- Fix array path handling for Standard Schema validators - Support both numeric (Zod) and string (Yup) array indices Fixes TanStack#1683
View your CI Pipeline Execution ↗ for commit 7428688
☁️ Nx Cloud last updated this comment at |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1689 +/- ##
=======================================
Coverage ? 90.51%
=======================================
Files ? 37
Lines ? 1698
Branches ? 424
=======================================
Hits ? 1537
Misses ? 144
Partials ? 17 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Looks promising! Thanks for tackling the issue. Let me know if you need more info or help with the PR.
…validator by inspecting form values
…/form into feat/standard-schema
Thank you for the excellent feedback! Your suggestions were spot-on and made the implementation much more robust. I really appreciate you pointing out the numeric object property issue and providing the better approach using actual form values as reference. The I've committed all the changes incorporating your feedback
Please review when you have a chance. Thanks for the great mentorship! |
Appreciate the work here, but something made me wonder... in the interest of openness, has this PR been created by AI by any chance? |
I wrote the bug fix logic myself. However, I did refer to some reference materials while searching for an efficient way to implement the code. Could this be a problem? |
@jiji-hoon96 I am not making any claims on the work itself. I was asking just out of curiosity based on the PR itself. No worries! ✌️ |
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.
LGTM! Let's see what the users from the issue have to say about it.
Description
This PR fixes a bug in the
prefixSchemaToErrors
function withinstandardSchemaValidator.ts
where array indices passed as strings (like '0', '1') were not being properly converted to bracket notation, causing validation errors for array fields to be incorrectly formatted.Problem
typeof normalizedSegment === 'number'
, missing string-based indicespeople.0.name
instead of the correctpeople[0].name
Solution
/^\d+$/
to identify string representations of numbersRelated Issue
Fixes #1683
Type of Change
Testing
Test Results
Code Changes
Before
After
Impact
Checklist