class Dry::Schema::Macros::Maybe
@api private
Macro used to specify predicates for a value that can be ‘nil`
def call(*args, **opts, &block)
- Api: - private
def call(*args, **opts, &block) if args.include?(:empty?) raise ::Dry::Schema::InvalidSchemaError, 'Using maybe with empty? predicate is invalid' end if args.include?(:nil?) raise ::Dry::Schema::InvalidSchemaError, 'Using maybe with nil? predicate is redundant' end value(*args, **opts, &block) self end
def to_ast
- Api: - private
def to_ast [:implication, [ [:not, [:predicate, [:nil?, [[:input, Undefined]]]]], trace.to_rule.to_ast ] ] end