-
Notifications
You must be signed in to change notification settings - Fork 89
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(manager): mutate error object on field-level validation. #703
Conversation
Codecov Report
@@ Coverage Diff @@
## state-manager #703 +/- ##
==============================================
Coverage 92.91% 92.92%
==============================================
Files 218 218
Lines 3488 3491 +3
Branches 1113 1115 +2
==============================================
+ Hits 3241 3244 +3
Misses 247 247
Continue to review full report at Codecov.
|
cebb62f
to
29c1f1b
Compare
@@ -1,9 +1,13 @@ | |||
import AnyObject from './any-object'; | |||
import { ManagerApi } from './manager-api'; | |||
|
|||
export interface FormLevelError { | |||
[key: string]: string; |
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 think we should support more types. I remember I was using <FormattedMessage />
to return translated message in Sources and it worked.
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.
Yeah, I was thinking about this as well. I think we might have to re-visit this topic for the whole package because the field level errors are locked to strings as well. And also all validator return values.
🎉 This PR is included in version 3.1.0 🎉 The release is available on Demo can be found here! |
part of #687
Only handles field-level validation
To enable it for form-level validation, we will need to register all validation functions and run them again after the form level validation passes. We need a way to clear form level validation errors, but do not remove field-level validation results at the same time. The only safe way I can think of is re-run all field-level validators, update the state, and possibly trigger the field render.
We will have also trigger the field render after we run form level validation for invalid fields.