sul-dlss / cocina-models

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

Validate descriptive dates per specified code #484

Closed mjgiarlo closed 2 years ago

mjgiarlo commented 2 years ago

Why was this change made? 🤔

Fixes https://github.com/sul-dlss/cocina-models/issues/392 Fixes https://github.com/sul-dlss/cocina-models/issues/483

This commit adds a new validator, but does not yet hook it up (follow-on work pending confirmation from Arcadia and Andrew), to make sure EDTF, ISO8601, and W3CDTF dates are valid per their specifications. To do the validation, we use upstream libraries in favor of rolling our own regexes or parsers because dragons, maybe.

One exception: the upstream W3CDTF parser flags two patterns we care about as invalid but per the spec should be valid. I briefly considered patching the library in question but this code has not been substantially touched in 10-15 years and I am loath to dig into it. In lieu of that, I added those cases in a one-liner that has code comments.

The tests written are currently incomplete, as I want to include some complex, nested Cocina structures to make sure the validator works against basic values, structured values, etc.

How was this change tested? 🤨

CI