lib/dry/schema/macros/dsl.rb in dry-schema-0.1.1 vs lib/dry/schema/macros/dsl.rb in dry-schema-0.2.0

- old
+ new

@@ -33,22 +33,43 @@ append_macro(Macros::Filled) do |macro| macro.call(*args, &block) end end - # Specify a nested schema + # Specify a nested hash without enforced hash? type-check # # @api public def schema(*args, &block) + append_macro(Macros::Schema) do |macro| + macro.call(*args, &block) + end + end + + # Specify a nested hash with enforced hash? type-check + # + # @see #schema + # + # @api public + def hash(*args, &block) append_macro(Macros::Hash) do |macro| macro.call(*args, &block) end end # Specify predicates that should be applied to each element of an array # # @api public def each(*args, &block) + append_macro(Macros::Each) do |macro| + macro.value(*args, &block) + end + end + + # Like `each`, but prepends `array?` check + # + # @api public + def array(*args, &block) + value(:array) append_macro(Macros::Each) do |macro| macro.value(*args, &block) end end