dataverse-frontend
dataverse-frontend copied to clipboard
Fix/393 Match api email validation
What this PR does / why we need it: Fixes a mismatch between the email validation of the SPA Dataset creation form and the email validation of the dataverse api. Also improves the UX to display the alert error banner only when creations fail, with messages specific to both the client-javascript api wrapper and the dataverse api itself (from the latter extracting only the field-related part of the error and not the part of the error related to Java invalid value exceptions).
Which issue(s) this PR closes:
Closes #393
Special notes for your reviewer:
Suggestions on how to test this:
Enter an invalid email ([email protected]) and check that the error message is displayed below the field.
It is a bit difficult to test the error messages in the banners as the validations are being fulfilled from the form before it is submitted.
One option could be to test locally, modifying the code so that no fields are required within the form and submitting the form, in useDefineRules.tsx
set the required property to false
.
Does this PR introduce a user interface change? If mockups are available, please link/include them here: The same error banner is maintained, only now when the user submits the form, if there is an error and this banner appears, it is automatically focused with an specific message about the error.
Error thrown from the dataverse api 👇
Error thrown from the client-javascript api wrapper 👇
How the error banner is focused 👇 In this example the client-side validations were removed just to show the focus case. alert-error-behaviour.webm
Is there a release notes update needed for this change?: No.
Additional documentation: No.