Skip to content
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

Integrate external errors in form #1937

Merged
merged 2 commits into from
May 23, 2022

Conversation

AlexandraBuzila
Copy link
Member

@AlexandraBuzila AlexandraBuzila commented May 19, 2022

Add support for specifying external errors via additionalErrors: ajv.ErrorObject[] prop.

The additional errors are merged with the validation errors and are
supplied to the affected controls. The additional errors are not
affected by the validationMode like the validation errors are and it is
the responsability of the framework user to update the prop when
applicable (e.g. on ValidationMode changes).

Fixes #1926

Contributed on behalf of STMicroelectronics

@coveralls
Copy link

coveralls commented May 19, 2022

Coverage Status

Coverage remained the same at 84.29% when pulling 243c034 on AlexandraBuzila:additional-errors into 8e9c14d on eclipsesource:master.

Copy link
Member

@sdirix sdirix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good already!

Can you add an example to the example app which adds/removes multiple additional errors on the click of a button?

) => (state: JsonFormsCore): ErrorObject[] => {
const errors = state.errors ?? [];
const additionalErrors = state.additionalErrors ?? [];
return errorsAt(instancePath, schema, matchPath)(state.validationMode === 'ValidateAndHide' ? [...additionalErrors] : [...errors, ...additionalErrors]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return errorsAt(instancePath, schema, matchPath)(state.validationMode === 'ValidateAndHide' ? [...additionalErrors] : [...errors, ...additionalErrors]);
return errorsAt(instancePath, schema, matchPath)(state.validationMode === 'ValidateAndHide' ? additionalErrors : [...errors, ...additionalErrors]);

Add support for specifying external errors via `additionalErrors:
ajv.ErrorObject[]` prop.

The additional errors are merged with the validation errors and are
supplied to the affected controls. The additional errors are not
affected by the validationMode like the validation errors are and it is
the responsability of the framework user to update the prop when
applicable (e.g. on ValidationMode changes).

Fixes eclipsesource#1926

Contributed on behalf of STMicroelectronics

Signed-off-by: Alexandra Buzila <abuzila@eclipsesource.com>
@AlexandraBuzila
Copy link
Member Author

Thank you for the review, Stefan! I updated the code and added examples for React (material and vanilla) and vue-vanilla. The contributed example should work with the angular examples as well when they'll support displaying buttons for the contributed actions like the React app (it's currently not the case).

Copy link
Member

@sdirix sdirix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thank you!

@sdirix sdirix merged commit 8026ada into eclipsesource:master May 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate external errors in form
3 participants