Class: SimplyStored::Couch::Validations::ValidatesFormatOf

Inherits:
Validatable::ValidationBase
  • Object
show all
Defined in:
lib/simply_stored/couch/validations.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#i18nObject



38
39
40
# File 'lib/simply_stored/couch/validations.rb', line 38

def i18n
  super || "#{i18n_prefix}.invalid"
end

#message(instance) ⇒ Object



34
35
36
# File 'lib/simply_stored/couch/validations.rb', line 34

def message(instance)
  super || "is invalid"
end

#valid?(instance) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
32
# File 'lib/simply_stored/couch/validations.rb', line 29

def valid?(instance)
  (allow_blank && instance.send(attribute).blank?) ||
    !(instance.send(self.attribute).to_s =~ self.with).nil?
end