Module: MotionModel::Validatable::ClassMethods

Defined in:
lib/motion_model/validatable.rb

Instance Method Summary collapse

Instance Method Details

#validate(field = nil, validation_type = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/motion_model/validatable.rb', line 9

def validate(field = nil, validation_type = {})
  if field.nil? || field.to_s == ''
    ex = ValidationSpecificationError.new('field not present in validation call')
    raise ex
  end
    
  if validation_type == {} # || !(validation_type is_a?(Hash))
    ex = ValidationSpecificationError.new('validation type not present or not a hash')
    raise ex
  end
    
  @validations << {field => validation_type}
end