-
-
Notifications
You must be signed in to change notification settings - Fork 440
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
base: main
Are you sure you want to change the base?
Conversation
View your CI Pipeline Execution ↗ for commit f671ab2.
☁️ 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.83% 89.00% +0.17%
==========================================
Files 31 31
Lines 1379 1401 +22
Branches 347 347
==========================================
+ Hits 1225 1247 +22
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
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.