module ActiveFolder::Model::Traits::Validation

Public Instance Methods

validate(attribute, schema, message = nil) click to toggle source
# File lib/activefolder/model/traits/validation.rb, line 9
def validate attribute, schema, message = nil
  before_save do
    unless schema.match(self.send attribute)
      raise ValidationError.new(attribute, schema, message)
    end
  end

  after_load do
    unless schema.match(self.send attribute)
      raise ValidationError.new(attribute, schema, message)
    end
  end
end