lib/dry/schema/macros/filled.rb in dry-schema-1.4.3 vs lib/dry/schema/macros/filled.rb in dry-schema-1.5.0
- old
+ new
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'dry/schema/macros/value'
+require "dry/schema/macros/value"
module Dry
module Schema
module Macros
# Macro used to prepend `:filled?` predicate
@@ -13,26 +13,26 @@
def call(*predicates, **opts, &block)
ensure_valid_predicates(predicates)
if opts[:type_spec] && !filter_empty_string?
value(predicates[0], :filled?, *predicates[1..predicates.size - 1], **opts, &block)
+ elsif opts[:type_rule]
+ value(:filled?).value(*predicates, **opts, &block)
else
value(:filled?, *predicates, **opts, &block)
end
end
# @api private
- # rubocop:disable Style/GuardClause
def ensure_valid_predicates(predicates)
if predicates.include?(:empty?)
- raise ::Dry::Schema::InvalidSchemaError, 'Using filled with empty? predicate is invalid'
+ raise ::Dry::Schema::InvalidSchemaError, "Using filled with empty? predicate is invalid"
end
if predicates.include?(:filled?)
- raise ::Dry::Schema::InvalidSchemaError, 'Using filled with filled? is redundant'
+ raise ::Dry::Schema::InvalidSchemaError, "Using filled with filled? is redundant"
end
end
- # rubocop:enable Style/GuardClause
# @api private
def filter_empty_string?
!expected_primitives.include?(NilClass) && processor_config.filter_empty_string
end