Sha256: acc8ba2574abdb6836786ab5cbf0b7cbe3fdd99619f0abbdd0681e4faaf600d5
Contents?: true
Size: 692 Bytes
Versions: 10
Compression:
Stored size: 692 Bytes
Contents
module DataMapper module Matchers def validate_presence_of(property) ValidatePresenceOf.new(property) end class ValidatePresenceOf < ValidationMatcher set_validation_subject "presence" def matches?(model) model_class = model.is_a?(Class) ? model : model.class validators = model_class.validators.contexts[:default] presence_of = validators.find do |validator| validator.is_a? DataMapper::Validations::PresenceValidator and validator.field_name == @property end return false unless presence_of return false if @msg and @msg != presence_of.options[:message] true end end end end
Version data entries
10 entries across 10 versions & 2 rubygems