Sha256: ae900f06a8cadd38af4ed0799164407f8783a4c7aed74ad6cfd6f59cebad11da
Contents?: true
Size: 739 Bytes
Versions: 19
Compression:
Stored size: 739 Bytes
Contents
require 'dry-struct' module Dry module Validation class Schema module StructClassBuilder 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 end module StructNode def node(input, *) if input.is_a?(::Class) && input < ::Dry::Struct [type, [name, [:schema, Schema.create_class(self, input)]]] else super end end end singleton_class.prepend(StructClassBuilder) Value.prepend(StructNode) end end end
Version data entries
19 entries across 19 versions & 1 rubygems