sul-dlss / cocina-models

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

Allow non-required custom types to be optional #571

Closed mjgiarlo closed 1 year ago

mjgiarlo commented 1 year ago

Why was this change made? 🤔

Custom types in Ruby models used to be "any" types, which allow null values. This change allows e.g. barcodes to be nulled out or reset. I discovered this deficiency in the models while rolling out cocina-models 0.87.0, and patched around it: https://github.com/sul-dlss/argo/blob/main/app/services/item_change_set_persister.rb#L134-L143. This cocina-models patch will allow the prior behavior of being able to reset these custom type values when the attribute is not required by adding logic around determining optionality.

How was this change tested? 🤨