-
-
Notifications
You must be signed in to change notification settings - Fork 512
feat(form-core): add <FieldMeta>.isValid
#1422
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
Conversation
View your CI Pipeline Execution ↗ for commit c7572f0.
☁️ Nx Cloud last updated this comment at |
For some reason, refactoring this FormApi check fails horribly. Does someone know why? - const isFieldsValid = !fieldMetaValues.some(
- (field) =>
- field?.errorMap &&
- isNonEmptyArray(Object.values(field.errorMap).filter(Boolean)),
- )
+ const isFieldsValid = fieldMetaValues.every(
+ (field) => field === undefined || field.isValid,
+ ) |
Does this work? const isFieldsValid = fieldMetaValues
.filter(Boolean)
.every((field) => field.isValid) |
No, but it's clear that the meta needs to be adjusted in some places. I'll tinker with it tomorrow. |
It's wild. I added checks wherever field errors or errorMap were tested for and it worked no problem. However, trying to rewrite |
e85bd89
to
e05fac4
Compare
It works now! This code wasn't the problem, but my implementation of |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1422 +/- ##
=======================================
Coverage 88.97% 88.98%
=======================================
Files 31 31
Lines 1397 1398 +1
Branches 353 353
=======================================
+ Hits 1243 1244 +1
Misses 137 137
Partials 17 17 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
this is a shortened counterpart to checking field.state.meta.errors.length > 0
e05fac4
to
1592ba1
Compare
…k-form into field-meta-is-valid
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.
That's great, thank you!
This meta property is a shortened alternative to checking
field.state.meta.errors.length === 0
. Since FormApi already has thisproperty, a FieldApi variant wouldn't hurt to be more clear.
This PR is based on Balastrong's suggestion on Discord.