Class: Cocina::Models::Validators::DarkValidator
- Inherits:
-
Object
- Object
- Cocina::Models::Validators::DarkValidator
- Defined in:
- lib/cocina/models/validators/dark_validator.rb
Overview
Validates that shelve and publish file attributes are set to false for dark DRO objects.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(clazz, attributes) ⇒ DarkValidator
constructor
A new instance of DarkValidator.
- #validate ⇒ Object
Constructor Details
#initialize(clazz, attributes) ⇒ DarkValidator
Returns a new instance of DarkValidator.
12 13 14 15 |
# File 'lib/cocina/models/validators/dark_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/dark_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 24 |
# File 'lib/cocina/models/validators/dark_validator.rb', line 17 def validate return unless meets_preconditions? return if invalid_files.empty? raise ValidationError, 'Not all files have dark access and/or are unshelved ' \ "when object access is dark: #{invalid_filenames}" end |