-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
@@ -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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@justinlittman if you happen to have a chance before departing and wanted to double-check this work before merging |
32f2602
to
3ff8766
Compare
@peetucket OK if I go ahead and merge this since I don't see any further notes from @justinlittman? |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 ...
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
107b42d
to
637c82f
Compare
637c82f
to
e3b429a
Compare
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 ofrelatedResource.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. ⚡