You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I "play" with it, I don't understand the error management.
2 consecutive use cases:
both childA and childB are empty:
=> childA is in success ('has-success' and 'ng-valid' classes) although it must be filled => how can we indicate the problem on the field ?
=> root2 is in error ('has-error' class and error "message": "Missing required property: childA", "path": "#/childA")
=> the global form is valid => how can we disabled a submit button ?
childA still empty, and childB is filled:
=> childA still in success
=> root2 still in error (with the same error)
=> root2 has now a second error "message": "Missing required property: childA", "path": "#/root2"
=> the global form is now invalid and has the error "message": "Missing required property: childA", "path": "#/childA"
It's very confusing:
Why the required error is set on the parent of the field instead of the field itself like for other errors (minLength etc.) ?
Why on the first level (not nested fields) there is not the problem ?
Why the childA error is "locked" at the parent level (and is not raised at the global form) ? And why it is "unlocked" if childB is filled ?
What is the correct way to manage errors ? In our custom widget code, shall we look at control.errors ? or errorMessages ? or formProperty._errors ?
The text was updated successfully, but these errors were encountered:
olivier-robin31
changed the title
Required nested field
Error management on required nested field
Jan 17, 2025
Here is a schema where I declare the childA as required (childA is nested under root2):
When I "play" with it, I don't understand the error management.
2 consecutive use cases:
both childA and childB are empty:
=> childA is in success ('has-success' and 'ng-valid' classes) although it must be filled => how can we indicate the problem on the field ?
=> root2 is in error ('has-error' class and error
"message": "Missing required property: childA", "path": "#/childA"
)=> the global form is valid => how can we disabled a submit button ?
childA still empty, and childB is filled:
=> childA still in success
=> root2 still in error (with the same error)
=> root2 has now a second error
"message": "Missing required property: childA", "path": "#/root2"
=> the global form is now invalid and has the error
"message": "Missing required property: childA", "path": "#/childA"
It's very confusing:
control.errors
? orerrorMessages
? orformProperty._errors
?The text was updated successfully, but these errors were encountered: