Method: Rubix::Model#validate

Defined in:
lib/rubix/models/model.rb

#validatetrue, false

Validate this record.

Override this method in a subclass and have it raise a Rubix::ValidationError if validation fails.

Returns:

  • (true, false)


131
132
133
134
135
136
# File 'lib/rubix/models/model.rb', line 131

def validate
  self.class.properties.each_pair do |property, options|
    raise ValidationError.new("A #{self.class.resource_name} must have a #{property}") if options[:required] && (self.send(property).nil? || self.send(property).empty?)
  end
  true
end