class Dry::Schema::Macros::Key
@api public
Base macro for specifying rules applied to a value found under a key
def filter(...)
- Api: - public
Returns:
-
(Macros::Key)
-
Other tags:
- See: Macros::Key#value -
Other tags:
- Example: check format before coercing to a date -
def filter(...) (filter_schema_dsl[name] || filter_schema_dsl.optional(name)).value(...) 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:, 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
- 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