lib/dry/schema/macros/dsl.rb in dry-schema-1.10.2 vs lib/dry/schema/macros/dsl.rb in dry-schema-1.10.3

- old
+ new

@@ -1,9 +1,7 @@ # frozen_string_literal: true -require "dry/logic/operators" - require "dry/schema/macros/core" require "dry/schema/predicate_inferrer" require "dry/schema/primitive_inferrer" module Dry @@ -78,9 +76,27 @@ # # @api public def filled(*args, **opts, &block) extract_type_spec(args) do |*predicates, type_spec:, type_rule:| append_macro(Macros::Filled) do |macro| + macro.call(*predicates, type_spec: type_spec, type_rule: type_rule, **opts, &block) + end + end + end + + # Set type specification and predicates for a maybe value + # + # @example + # required(:name).maybe(:string) + # + # @see Macros::Key#value + # + # @return [Macros::Key] + # + # @api public + def maybe(*args, **opts, &block) + extract_type_spec(args, nullable: true) do |*predicates, type_spec:, type_rule:| + append_macro(Macros::Maybe) do |macro| macro.call(*predicates, type_spec: type_spec, type_rule: type_rule, **opts, &block) end end end