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)
- Api: - public
Returns:
-
(Macros::Key)
-
Other tags:
- See: Macros::Key#value -
def filled(*args, **opts, &block) extract_type_spec(*args) do |*predicates, type_spec:| super(*predicates, type_spec: type_spec, **opts, &block) end end
def filter(*args, &block)
- 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)
- 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:| append_macro(Macros::Maybe) do |macro| macro.call(*predicates, **opts, &block) end end end
def to_ast
- Api: - private
def to_ast [:predicate, [:key?, [[:name, name], [:input, Undefined]]]] end
def to_rule
- 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)
- 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:| super(*predicates, type_spec: type_spec, **opts, &block) end end