class Dry::Schema::Macros::Key

@api public
Base macro for specifying rules applied to a value found under a key

def filled(*args, **opts, &block)

Other tags:
    Api: - public

Returns:
  • (Macros::Key) -

Other tags:
    See: Macros::Key#value -
def filled(*args, **opts, &block)
  extract_type_spec(*args) do |*predicates, type_spec:, type_rule:|
    super(*predicates, type_spec: type_spec, type_rule: type_rule, **opts, &block)
  end
end

def filter(*args, &block)

Other tags:
    Api: - public

Returns:
  • (Macros::Key) -

Other tags:
    See: Macros::Key#value -

Other tags:
    Example: check format before coercing to a date -
def filter(*args, &block)
  (filter_schema_dsl[name] || filter_schema_dsl.optional(name)).value(*args, &block)
  self
end

def maybe(*args, **opts, &block)

Other tags:
    Api: - public

Returns:
  • (Macros::Key) -

Other tags:
    See: Macros::Key#value -
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

def to_ast

Other tags:
    Api: - private
def to_ast
  [:predicate, [:key?, [[:name, name], [:input, Undefined]]]]
end

def to_rule

Other tags:
    Api: - private

Returns:
  • (Dry::Logic::Rule) -
def to_rule
  if trace.captures.empty?
    super
  else
    [super, trace.to_rule(name)].reduce(operation)
  end
end

def value(*args, **opts, &block)

Other tags:
    Api: - public

Other tags:
    See: Macros::DSL#value -

Returns:
  • (Macros::Key) -

Other tags:
    Example: with a block -
    Example: with a predicate with arguments -
    Example: with a predicate -

Parameters:
  • predicate_opts (Hash) --
  • predicates (Array) --
  • type_spec (Symbol, Types::Type, Array) --

Overloads:
  • value(type_spec, *predicates, **predicate_opts)
def value(*args, **opts, &block)
  extract_type_spec(*args) do |*predicates, type_spec:, type_rule:|
    super(*predicates, type_spec: type_spec, type_rule: type_rule, **opts, &block)
  end
end