Class: Cocina::Models::Validators::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/cocina/models/validators/validator.rb

Overview

Perform validation against all other Validators

Constant Summary collapse

VALIDATORS =
[
  OpenApiValidator,
  DarkValidator,
  PurlValidator,
  CatalogLinksValidator,
  AssociatedNameValidator,
  DescriptionTypesValidator,
  DescriptionValuesValidator,
  DateTimeValidator,
  LanguageTagValidator,
  ReservedFilenameValidator
].freeze

Class Method Summary collapse

Class Method Details

.validate(clazz, attributes) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/cocina/models/validators/validator.rb', line 21

def self.validate(clazz, attributes)
  # This gets rid of nested model objects.
  attributes_hash = attributes.to_h.deep_transform_values do |value|
    value.class.name.starts_with?('Cocina::Models') ? value.to_h : value
  end.with_indifferent_access
  VALIDATORS.each { |validator| validator.validate(clazz, attributes_hash) }
end