Sha256: 36fb5de2b08a6a6cd858f31af3c5a49f5f066b1b9c5cd3c037fe6202707e1193
Contents?: true
Size: 910 Bytes
Versions: 14
Compression:
Stored size: 910 Bytes
Contents
# frozen_string_literal: true require 'dry/schema/macros/dsl' module Dry module Schema module Macros # Macro used to specify predicates for a value that can be `nil` # # @api private class Maybe < DSL # @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 # @api private def to_ast [:implication, [ [:not, [:predicate, [:nil?, [[:input, Undefined]]]]], trace.to_rule.to_ast ] ] end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems