Skip to content

Conversation

@g-saracca
Copy link
Contributor

@g-saracca g-saracca commented Oct 2, 2025

What this PR does / why we need it:

Fixes some differences on how we were validating the DATE fields different than the backend.
Also includes the invalid value entered by the user in error messages for URL and EMAIL fields.
More info in "Suggestions on how to test this" and screenshots.

Which issue(s) this PR closes:

Special notes for your reviewer:

Suggestions on how to test this:

Log in in both SPA and JSF and navigate to the create dataset page on each.

Pick a DATE field like Deposit Date.
Validate that valid values entered in the JSF form are valid also in the SPA. (for the JSF you will need to submit the form to check if an error appears - for the SPA it will be shown as you type)
Validate that invalid values entered in the JSF form are invalid also in the SPA ( the spa will show error messages with more info)

For example these are the valid and invalid cases that I've used for the unit tests.

Validate that the invalid value entered by the user is included in the error message for URL and EMAIL fields.

Does this PR introduce a user interface change? If mockups are available, please link/include them here:

Yes, not really a user interface change but some new error messages.

Showing the invalid value entered by the user in the error message for EMAIL and URL type fields. 👇

Screenshot 2025-10-03 at 14 50 16 Screenshot 2025-10-03 at 14 50 38

New validations and error messages for DATE field type. 👇

Screenshot 2025-10-03 at 14 52 19 Screenshot 2025-10-03 at 14 52 39 Screenshot 2025-10-03 at 14 53 04 Screenshot 2025-10-03 at 14 53 56 Screenshot 2025-10-03 at 14 54 12 Screenshot 2025-10-03 at 14 54 27 Screenshot 2025-10-03 at 14 53 24 Screenshot 2025-10-03 at 14 55 44 Screenshot 2025-10-03 at 14 54 40

Is there a release notes or changelog update needed for this change?:

Yes, added to the CHANGELOG.

@coveralls
Copy link

coveralls commented Oct 2, 2025

Coverage Status

coverage: 97.13% (-0.1%) from 97.227%
when pulling 0f2ecd2 on fix/847-dataset-metadata-field-validations
into a3f4b8b on develop.

@g-saracca g-saracca marked this pull request as ready for review October 3, 2025 18:24
@g-saracca g-saracca moved this to Ready for Review ⏩ in IQSS Dataverse Project Oct 3, 2025
@jggautier
Copy link
Contributor

jggautier commented Oct 3, 2025

Hey @g-saracca! I think this is a great improvement, not just for making the date validation work in the SPA in the same way that it does for the JSF version of Dataverse, but also for making the error messages much more helpful. Right now in the JSF version, it looks like no matter what a user enters in a date field, the error message is always "Description Date is not a valid date. "yyyy" is a supported format.", which is true but misleading, since "yyyy" is just one of the dozens of types of dates that are allowed.

And even the review you did should make it much more clear to the rest of the team and the Dataverse community what types of dates currently are and aren't allowed, and why these rules were created in the first place. This shared understanding should make it much easier to keep improving things!

@ChengShi-1 ChengShi-1 requested a review from Copilot October 3, 2025 22:36
@ChengShi-1 ChengShi-1 self-assigned this Oct 3, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes dataset metadata field validations to better align with the backend validation system. The changes enhance error messages for URL and EMAIL fields by including the invalid value entered by the user, and implement comprehensive date field validation that closely mirrors the backend validation logic.

  • Replaces existing validation functions with enhanced implementations that provide better error messaging
  • Implements comprehensive date validation with specific error codes for different failure scenarios
  • Consolidates validation logic into centralized helper classes for better maintainability

Reviewed Changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/component/sections/shared/dataset-metadata-form/MetadataFieldsHelper.spec.ts Adds comprehensive test coverage for the new date validation functionality
tests/component/sections/shared/dataset-metadata-form/DatasetMetadataForm.spec.tsx Updates test expectations to match new error message format including user input
tests/component/sections/edit-dataset-metadata/EditDatasetMetadata.spec.tsx Adds missing test setup for create mode metadata blocks
src/shared/helpers/Validator.ts Adds new validation methods for URL, hostname, and float validation
src/sections/shared/form/DatasetMetadataForm/useSubmitDataset.ts Updates import to use centralized validation error handling
src/sections/shared/form/DatasetMetadataForm/MetadataForm/MetadataBlockFormFields/MetadataFormField/useDefineRules.ts Updates to use new validation methods and enhanced error messaging
src/sections/shared/form/DatasetMetadataForm/MetadataFieldsHelper.ts Implements comprehensive date validation logic and error handling
src/sections/dataset/deaccession-dataset/DeaccessionDatasetModal.tsx Updates to use centralized URL validation
src/metadata-block-info/domain/models/fieldValidations.ts Removes old validation functions that have been moved to centralized helpers
src/metadata-block-info/domain/models/MetadataBlockInfo.ts Removes unused date format constants
public/locales/en/shared.json Updates error message templates to include user input and detailed date error messages
package.json Updates dataverse client dependency version
CHANGELOG.md Documents the validation improvements

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ChengShi-1 ChengShi-1 moved this from Ready for Review ⏩ to In Review 🔎 in IQSS Dataverse Project Oct 3, 2025
@ChengShi-1 ChengShi-1 added GREI Re-arch GREI re-architecture-related FY26 Sprint 7 FY26 Sprint 7 (2025-09-24 - 2025-10-08) Size: 3 A percentage of a sprint. 2.1 hours. Original size: 3 labels Oct 3, 2025
Copy link
Contributor

@ChengShi-1 ChengShi-1 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! just need update package and changelog once they're ready

@ChengShi-1 ChengShi-1 assigned g-saracca and ChengShi-1 and unassigned ChengShi-1 Oct 6, 2025
@cmbz cmbz added the FY26 Sprint 8 FY26 Sprint 8 (2025-10-08 - 2025-10-22) label Oct 8, 2025
@g-saracca
Copy link
Contributor Author

@ChengShi-1 changes done.

@g-saracca g-saracca removed their assignment Oct 9, 2025
Copy link
Contributor

@ChengShi-1 ChengShi-1 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!

@github-project-automation github-project-automation bot moved this from In Review 🔎 to Ready for QA ⏩ in IQSS Dataverse Project Oct 9, 2025
@ChengShi-1 ChengShi-1 removed their assignment Oct 9, 2025
@ofahimIQSS ofahimIQSS self-assigned this Oct 9, 2025
@ofahimIQSS ofahimIQSS moved this from Ready for QA ⏩ to QA ✅ in IQSS Dataverse Project Oct 9, 2025
@ofahimIQSS
Copy link
Contributor

very nice, all the messaging looks good. I even tested with leap year dates, that worked as well.

@ofahimIQSS ofahimIQSS merged commit 768110c into develop Oct 9, 2025
13 of 14 checks passed
@github-project-automation github-project-automation bot moved this from QA ✅ to Merged 🚀 in IQSS Dataverse Project Oct 9, 2025
@ofahimIQSS ofahimIQSS removed their assignment Oct 9, 2025
@pdurbin pdurbin moved this from Merged 🚀 to Done 🧹 in IQSS Dataverse Project Oct 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FY26 Sprint 7 FY26 Sprint 7 (2025-09-24 - 2025-10-08) FY26 Sprint 8 FY26 Sprint 8 (2025-10-08 - 2025-10-22) GREI Re-arch GREI re-architecture-related Original size: 3 Size: 3 A percentage of a sprint. 2.1 hours.

Projects

Status: Done 🧹

Development

Successfully merging this pull request may close these issues.

Create/Edit Dataset Metadata Form field validations differences

7 participants