Module: Dry::Validation::Schema::StructClassBuilder

Included in:
Dry::Validation::Schema
Defined in:
lib/dry/validation/extensions/struct.rb

Instance Method Summary collapse

Instance Method Details

#create_class(target, other = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/dry/validation/extensions/struct.rb', line 7

def create_class(target, other = nil)
  if other.is_a?(Class) && other < Dry::Struct
    super do
      other.schema.each { |attr, type| required(attr).filled(type) }
    end
  else
    super
  end
end