Sha256: 1f864f2530b937804e45cb3b577f36ca1c959be1729e1aab9f5ecc3ab1f96e61
Contents?: true
Size: 469 Bytes
Versions: 4
Compression:
Stored size: 469 Bytes
Contents
module Validatable class ValidatesPresenceOf < ValidationBase #:nodoc: def valid?(instance) value = instance.send(self.attribute) return true if allow_nil && value.nil? return true if allow_blank && value.blank? return false if instance.send(self.attribute).nil? value.respond_to?(:strip) ? instance.send(self.attribute).strip.length != 0 : true end def message(instance) super || "can't be blank" end end end
Version data entries
4 entries across 4 versions & 1 rubygems