Skip to content

Commit 768110c

Browse files
authored
Merge pull request #848 from IQSS/fix/847-dataset-metadata-field-validations
Fix/847 dataset metadata field validations
2 parents 322f73f + 0f2ecd2 commit 768110c

File tree

12 files changed

+443
-151
lines changed

12 files changed

+443
-151
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ This changelog follows the principles of [Keep a Changelog](https://keepachangel
88

99
### Added
1010

11+
- Added the value entered by the user in the error messages for metadata field validation errors in EMAIL and URL type fields. For example, instead of showing “Point of Contact E-mail is not a valid email address.“, we now show “Point of Contact E-mail foo is not a valid email address.”
12+
1113
### Changed
1214

1315
- Use of the new `sourceLastUpdateTime` query parameter from update dataset and file metadata endpoints to support optimistic concurrency control during editing operations. See [Edit Dataset Metadata](https://guides.dataverse.org/en/6.8/api/native-api.html#edit-dataset-metadata) and [Updating File Metadata](https://guides.dataverse.org/en/6.8/api/native-api.html#updating-file-metadata) guides for more details.
16+
- Changed the way we were handling DATE type metadata field validation to better match the backend validation and give users better error messages. For example, for an input like “foo AD”, we now show “Production Date is not a valid date. The AD year must be numeric.“. For an input like “99999 AD”, we now show “Production Date is not a valid date. The AD year cant be higher than 9999.“. For an input like “[-9999?], we now show “Production Date is not a valid date. The year in brackets cannot be negative.“, etc.
1417

1518
### Fixed
1619

public/locales/en/shared.json

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,23 @@
6262
"field": {
6363
"required": "{{displayName}} is required",
6464
"invalid": {
65-
"url": "{{displayName}} is not a valid URL",
66-
"email": "{{displayName}} is not a valid email",
67-
"int": "{{displayName}} is not a valid integer",
68-
"float": "{{displayName}} is not a valid float",
69-
"date": "{{displayName}} is not a valid date. Please use the format {{dateFormat}}"
65+
"url": "{{displayName}} {{value}} is not a valid URL.",
66+
"email": "{{displayName}} {{value}} is not a valid email.",
67+
"int": "{{displayName}} is not a valid integer.",
68+
"float": "{{displayName}} is not a valid float.",
69+
"date": {
70+
"base": "{{displayName}} is not a valid date.",
71+
"empty": "The date is empty.",
72+
"adDigits": "The AD year must be numeric.",
73+
"adRange": "The AD year can't be higher than 9999.",
74+
"bracketNotNumeric": "The year in brackets must be numeric.",
75+
"bracketNegative": "The year in brackets cannot be negative.",
76+
"bracketRange": "The year in brackets is out of range.",
77+
"invalidMonth": "The month is out of range.",
78+
"invalidDay": "The day is out of range.",
79+
"invalidTime": "The time is out of range.",
80+
"unrecognized": "The date format is unrecognized."
81+
}
7082
}
7183
},
7284
"status": {

src/metadata-block-info/domain/models/MetadataBlockInfo.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,6 @@ export const WatermarkMetadataFieldOptions = {
7676
export type WatermarkMetadataField =
7777
(typeof WatermarkMetadataFieldOptions)[keyof typeof WatermarkMetadataFieldOptions]
7878

79-
export const DateFormatsOptions = {
80-
YYYY: 'YYYY',
81-
YYYYMM: 'YYYY-MM',
82-
YYYYMMDD: 'YYYY-MM-DD'
83-
} as const
84-
85-
export type DateFormats = (typeof DateFormatsOptions)[keyof typeof DateFormatsOptions]
86-
8779
export interface MetadataBlockInfoDisplayFormat {
8880
name: string
8981
displayName: string

src/metadata-block-info/domain/models/fieldValidations.ts

Lines changed: 0 additions & 105 deletions
This file was deleted.

src/sections/dataset/deaccession-dataset/DeaccessionDatasetModal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Alert, Button, Col, Form, Modal, Stack } from '@iqss/dataverse-design-s
77
import { useDataset } from '../DatasetContext'
88
import { Deaccessioned } from '@/dataset/domain/models/DatasetVersionSummaryInfo'
99
import { DatasetRepository } from '@/dataset/domain/repositories/DatasetRepository'
10-
import { isValidURL } from '@/metadata-block-info/domain/models/fieldValidations'
10+
import { Validator } from '@/shared/helpers/Validator'
1111
import { useGetDatasetVersionsSummaries } from '../dataset-versions/useGetDatasetVersionsSummaries'
1212
import { DeaccessionFormData } from './DeaccessionFormData'
1313
import { ConfirmationModal } from './ConfirmationModal'
@@ -100,7 +100,7 @@ export function DeaccessionDatasetModal({
100100
if (value.trim() === '') {
101101
return true // Consider empty strings as valid
102102
}
103-
return isValidURL(value)
103+
return Validator.isValidURL(value)
104104
}
105105

106106
const handleCloseWithReset = () => {

0 commit comments

Comments
 (0)