I’m trying to achieve something like the following:
module CommonPredicates include Dry::Logic::Predicates predicate(:foo?) do |value| ! value.nil? end end module MyPredicates include Dry::Logic::Predicates predicate(:email?) do |value| ! /magical-regex-that-matches-emails/.match(value).nil? end end schema = Dry::Validation.Schema do configure do predicates(CommonPredicates) predicates(MyPredicates) # the second 'predicates(...)' overwrites the first one end required(:email).filled(:foo?, :email?) end
I’ve tried every way I can think of (although I will admit being a newbie with dry-validation). I’m using dry-validation to validate user input.
Thanks in advance…