Class: Cocina::Models::Validators::ReservedFilenameValidator
- Inherits:
-
Object
- Object
- Cocina::Models::Validators::ReservedFilenameValidator
- Defined in:
- lib/cocina/models/validators/reserved_filename_validator.rb
Overview
Validates that bare external identifier not used as a root filename or directory. This is necessary due to the bare druid being used as part of the Stacks file layout.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(clazz, attributes) ⇒ ReservedFilenameValidator
constructor
A new instance of ReservedFilenameValidator.
- #validate ⇒ Object
Constructor Details
#initialize(clazz, attributes) ⇒ ReservedFilenameValidator
Returns a new instance of ReservedFilenameValidator.
13 14 15 16 |
# File 'lib/cocina/models/validators/reserved_filename_validator.rb', line 13 def initialize(clazz, attributes) @clazz = clazz @attributes = attributes end |
Class Method Details
.validate(clazz, attributes) ⇒ Object
9 10 11 |
# File 'lib/cocina/models/validators/reserved_filename_validator.rb', line 9 def self.validate(clazz, attributes) new(clazz, attributes).validate end |
Instance Method Details
#validate ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/cocina/models/validators/reserved_filename_validator.rb', line 18 def validate return unless dro? return if filenames.none? { |filename| reserved?(filename) } raise ValidationError, 'Bare druid may not be used as a filename or a base directory' end |