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
fix: trigger validation netsted field #11336
base: master
Are you sure you want to change the base?
fix: trigger validation netsted field #11336
Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
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! Thank you for the contribution. Sorry I have been busy and completely miss the PR>
looks like test is failed. |
<button | ||
type="button" | ||
onClick={() => { | ||
setValue('item1.positions', [{ activities: [] }]); |
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.
@bluebill1049 To check #10862 . How about this?
setValue("item1.positions", [{ activities:[] }], {
shouldValidate: true
});
setValue("item2.positions.0.activities",[], {
shouldValidate: true
});
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.
yea, i did. I think it would be rather difficult to set inputs to empty values. if they are deeply nested. so it's better let the users at the app level doing that setValue within a loop. thanks a lot for your help and contribution tho.
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.
How about incorporating this change into'should be able to set to empty array value'
tests? The existing test failed because only one side(item1.positions
) was modified (item2.positions
not modified).
If you confirm, I will change it.
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.
@bluebill1049 Please check it.
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.
sorry, miss the pr. please update PR and I will review it again.
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.
I updated it!
thank you for your contribution! <3 |
@bluebill1049 Can it be merged into the |
To fix #10862 .
To ensure that an empty array [] is considered a valid value and correctly triggers validation when shouldValidate is set to true, I add the condition
isEmptyNonPrimitive
.I want to add tests for the cases of an empty object and an empty array in
setValue.test.tsx
, but I'm not sure what to compare. Can you help me with this?