Class: Cocina::Models::Validators::PurlValidator
- Inherits:
-
Object
- Object
- Cocina::Models::Validators::PurlValidator
- Defined in:
- lib/cocina/models/validators/purl_validator.rb
Overview
Validates that Purl matches the external identifier (druid)
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(clazz, attributes) ⇒ PurlValidator
constructor
A new instance of PurlValidator.
- #validate ⇒ Object
Constructor Details
#initialize(clazz, attributes) ⇒ PurlValidator
Returns a new instance of PurlValidator.
12 13 14 15 |
# File 'lib/cocina/models/validators/purl_validator.rb', line 12 def initialize(clazz, attributes) @clazz = clazz @attributes = attributes end |
Class Method Details
.validate(clazz, attributes) ⇒ Object
8 9 10 |
# File 'lib/cocina/models/validators/purl_validator.rb', line 8 def self.validate(clazz, attributes) new(clazz, attributes).validate end |
Instance Method Details
#validate ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/cocina/models/validators/purl_validator.rb', line 17 def validate return unless meets_preconditions? return if identifier_from_druid == identifier_from_purl raise ValidationError, "Purl mismatch: #{druid} purl does not match object druid." end |