class Reorm::PresenceValidator

Public Class Methods

new(*field) click to toggle source
Calls superclass method
# File lib/reorm/validators/presence_validator.rb, line 7
def initialize(*field)
  super("cannot be blank.", *field)
end

Public Instance Methods

validate(object) click to toggle source
# File lib/reorm/validators/presence_validator.rb, line 11
def validate(object)
  if !field.exists?(object) || [nil, ""].include?(field.value(object))
    object.errors.add(field.to_s, message)
  end
end