sul-dlss / cocina-models

Cocina repository data model (implemented in Ruby)
https://sul-dlss.github.io/cocina-models/
3 stars 0 forks source link

Validation: only one of value, parallelValue, groupedValue, and structuredValue should be present #424

Closed arcadiafalcone closed 2 years ago

arcadiafalcone commented 2 years ago

On the same level an object should have either a value or a structuredValue, not both.

justinlittman commented 2 years ago

Can you provide an example?

arcadiafalcone commented 2 years ago

The following would be invalid:

{ title: [ {
  value: 'A title',
  structuredValue: [ { value: 'A', type: 'nonsorting characters'}, { value: 'title', type: 'main title' } ] } ] }

A valid representation:

{ title: [ {
  parallelValue: [
    { value: 'A title' },
    { structuredValue: [ { value: 'A', type: 'nonsorting characters'}, { value: 'title', type: 'main title' } ] } ] } ] }
jcoyne commented 2 years ago

This seems like an issue with how we've written DescriptiveBasicValue. We say it has a structuredValue and a value field.

https://github.com/sul-dlss/cocina-models/blob/main/openapi.yml#L694-L707t

arcadiafalcone commented 2 years ago

I'm realizing this is also true of parallelValue and groupedValue -- a set of siblings in an object should have no more than one of the four.

This has not yet come up in our data but will be an issue for Cocina spreadsheet upload.

justinlittman commented 2 years ago

I've made an attempt at implementing this in openapi but was unsuccessful. I encourage someone else to make an attempt.

In addition to one of value, parallelValue, groupedValue, and structuredValue it must also support none being present.