Module: Cocina::Models::Validatable

Extended by:
ActiveSupport::Concern
Included in:
AdminPolicy, AdminPolicyWithMetadata, Collection, CollectionWithMetadata, DRO, DROWithMetadata, Description, RequestAdminPolicy, RequestCollection, RequestDRO, RequestDescription
Defined in:
lib/cocina/models/validatable.rb

Overview

Validate upon construction

Instance Method Summary collapse

Instance Method Details

#new(*args) ⇒ Object



16
17
18
19
20
21
# File 'lib/cocina/models/validatable.rb', line 16

def new(*args)
  validate = args.first.delete(:validate) if args.present?
  new_model = super
  Validators::Validator.validate(new_model.class, new_model) if validate || validate.nil?
  new_model
end