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

Validate for title.structuredValue.value having a type #675

Merged
merged 2 commits into from
Jan 30, 2024

Conversation

lwrubel
Copy link
Contributor

@lwrubel lwrubel commented Jan 24, 2024

Why was this change made? 🤔

Validator to address sul-dlss/argo#4279. This goes down one level of nesting (title.structuredValue) and also validates one level of relatedResource.title.structuredValue.

How was this change tested? 🤨

Unit. Ran bin/validate-cocina on QA, stage, and prod and there were no existing objects with this problem.

⚡ ⚠ If this change has cross service impact, run integration tests and/or test in [stage|qa] environment, in addition to specs. ⚡

@@ -64,6 +67,14 @@ def validate_values_for_multiples(hash, path)
error_paths_multiple << path_to_s(path)
end

def validate_title_type(hash, path)
# only apply to title.structuredValue with value
return unless hash[:value] && path.include?(:title) && path.include?(:structuredValue)
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering if this might match too broadly. Can you check for "title" and "structuredValue" in particular locations in the path?

Copy link
Contributor Author

@lwrubel lwrubel Jan 25, 2024

Choose a reason for hiding this comment

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

Thanks, I made some updates to this, also as part of checking relatedResource titles. There may be some variations of cocina that I'm not thinking of, however.

@lwrubel lwrubel marked this pull request as ready for review January 25, 2024 20:00
@lwrubel lwrubel changed the title [DRAFT] Validate for title.structuredValue.value having a type Validate for title.structuredValue.value having a type Jan 25, 2024
Copy link
Member

@peetucket peetucket left a comment

Choose a reason for hiding this comment

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

LGTM

@peetucket
Copy link
Member

@justinlittman if you happen to have a chance before departing and wanted to double-check this work before merging

@lwrubel lwrubel force-pushed the title-value-type-validator branch 2 times, most recently from 32f2602 to 3ff8766 Compare January 29, 2024 15:25
@lwrubel
Copy link
Contributor Author

lwrubel commented Jan 29, 2024

@peetucket OK if I go ahead and merge this since I don't see any further notes from @justinlittman?

Copy link
Contributor

@ndushay ndushay left a comment

Choose a reason for hiding this comment

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

just a note about using "third". ow. looks good.

end

def related_resource_title?(path)
path.first == :relatedResource && path.third == :title
Copy link
Contributor

Choose a reason for hiding this comment

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

what is second? structuredValue or parallelValue or something? It's theoretically possible to have structuredValues inside parallelValues ...

Copy link
Member

Choose a reason for hiding this comment

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

Is there an easy way to model that scenario in another spec and see what happens? Do you think that should block this fix?

Copy link
Contributor Author

@lwrubel lwrubel Jan 29, 2024

Choose a reason for hiding this comment

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

When I talked this through with Justin, we went down the path of keeping this in structuredValue only. Not further nesting or other situations.

The path it's looking for would be [:title, 0, :structuredValue, 0] in order to validate the presence of a type in the hash. (could be a different value than 0 of course)

Is there a way you'd recommend we do this? I don't doubt there's something I'm not understanding here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ndushay and I took a look at this and I'll add in the case to handle title.parallelValue.structuredValue. @arcadiafalcone says: this would likely be coming from a MARC record, so with Google Books it's not that uncommon.

Copy link
Contributor Author

@lwrubel lwrubel Jan 30, 2024

Choose a reason for hiding this comment

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

@ndushay see added specs to cover title.parallelValue.structuredValue and relatedResource.title.parallelValue.structuredValue situations. Because the logic is to check for structuredValue in the path, as a descendant of title but not necessarily an immediate descendant, there is room for a parallelValue to exist in the path. I think this is OK for titles?

I also updated some comments to improve clarity, based on our conversation.

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.

4 participants