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

[HOLD] Fix validation of description values including title #681

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lwrubel
Copy link
Contributor

@lwrubel lwrubel commented Feb 5, 2024

Why was this change made? 🤔

HOLD because data in prod needs remediation.
Follow-on to #675 (see sul-dlss/argo#4279 and also #424) to make sure that ValidationError is raised in several invalid title and other DescriptiveValue situations.

How was this change tested?

Unit. When running a dor-services-app instance locally in docker with the cocina-models branch, error is raised by DSA when an invalid update sent from Argo spreadsheet upload.

Ran bin/validate-cocina. There are 244 invalid druids in prod, none in qa or stage. Gave @arcadiafalcone the list of problem druids for remediation in sul-dlss/argo#4279. They are all for "Multiple value, groupedValue, structuredValue, and parallelValue in description" errors.

@@ -62,22 +62,30 @@ def validate_values_for_blanks(hash, path)
end

def validate_values_for_multiples(hash, path)
return unless hash.count { |key, value| %i[value groupedValue structuredValue parallelValue].include?(key) && value.present? } > 1
return unless hash.count { |key, value| %w[value groupedValue structuredValue parallelValue].include?(key) && value.present? } > 1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

keys are strings, rather than symbols.

Copy link
Member

@mjgiarlo mjgiarlo Feb 5, 2024

Choose a reason for hiding this comment

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

How do we know these keys are strings?

The entrypoint to the DescriptionValuesValidator class is the Validator class, which converts the attributes to be validated into a HashWithIndifferentAccess instance.

The HashWithIndifferentAccess class maps symbol keys to string keys in its writing interface. Thus:

[y]ou are guaranteed that the key is returned as a string

(see https://api.rubyonrails.org/classes/ActiveSupport/HashWithIndifferentAccess.html)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for explaining/documenting this in detail!

@lwrubel lwrubel changed the title [DRAFT] Fix validation of description title [HOLD] Fix validation of description title Feb 5, 2024
@lwrubel lwrubel changed the title [HOLD] Fix validation of description title [HOLD] Fix validation of description values including title Feb 5, 2024
@lwrubel lwrubel marked this pull request as ready for review February 5, 2024 21:44
Copy link
Member

@mjgiarlo mjgiarlo left a comment

Choose a reason for hiding this comment

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

Yay!

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.

2 participants