Skip to content

Issue #801: Added regex pattern to Name & UniqueName fields and custo…#822

Draft
ahungerford-unicon wants to merge 3 commits intomainfrom
issue/801
Draft

Issue #801: Added regex pattern to Name & UniqueName fields and custo…#822
ahungerford-unicon wants to merge 3 commits intomainfrom
issue/801

Conversation

@ahungerford-unicon
Copy link
Contributor

@ahungerford-unicon ahungerford-unicon commented Jan 30, 2026

…m error checking for those fields

Edit: Changed it to a Draft as this requires #810 to be completed first.

Comment on lines +96 to +99
// # Disabled pattern validation here; now handled on handleCreateOrEdit
// if (field.pattern && createParams[field.name] && !new RegExp(field.pattern).test(createParams[field.name])) {
// setCreateError(`The following fields have invalid values:\n > ${field.patternErr}`);
// }
Copy link
Contributor Author

@ahungerford-unicon ahungerford-unicon Jan 30, 2026

Choose a reason for hiding this comment

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

Left this in but commented as I originally had this checking as the field was edited, but wasn't really satisfied with the result since it would replace any onSave reported errors as soon as you started to correct one of them. I believe we could get inline checking done without this if we updated the Dialog to an actual form, since that is how the pattern attribute usually works, but my quick tests with it caused other issues to crop up for Dialog that didn't make it worth it.

@ahungerford-unicon ahungerford-unicon marked this pull request as draft January 30, 2026 17:36
Copy link
Contributor

@bjagg bjagg left a comment

Choose a reason for hiding this comment

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

Hey @ahungerford-unicon — took a look at this while reviewing open PRs. The implementation approach is clean (validating on submit, patternErr for custom messages, whiteSpace: pre-line for multi-line errors). Nice call avoiding the inline validation — that's the right tradeoff for a dialog.

One concern with the regex ^[A-Za-z][A-Za-z0-9_]*$: it would be too restrictive for the existing UniqueName conventions in the MDR data. Looking at the seed data in V1.1__metadata_repository_init.sql, UniqueName values routinely use dots as path separators:

  • Common.Contact.Address.informationSourceId
  • Assessment.shortName
  • achievement.achievementType

There are hundreds of entries following this dotted-path pattern. Even after #810 removes spaces, dots would still be needed for UniqueName. The current regex would prevent creating or editing any entries that follow the existing convention.

A few thoughts:

  1. Name vs UniqueName may need different regexes. Name fields (firstName, Identifier) tend to be simple identifiers, but UniqueName fields (Common.Contact.Address.informationSourceId) use dotted paths. Something like ^[A-Za-z][A-Za-z0-9_.]*$ for UniqueName might work better.

  2. Worth aligning with #811 (API validation) before finalizing the regex here — the frontend and backend should enforce the same rules.

  3. Value Names (the last field updated in CreateOptFields.tsx) may have different conventions than entity/attribute names — worth checking if those need dots too.

Happy to help dig into the data further if useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants