Class: SexyValidations::Validators::Format

Inherits:
Object
  • Object
show all
Defined in:
lib/sexy_validations/validators/format.rb

Class Method Summary collapse

Class Method Details

.validate(model, attribute, value, options) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/sexy_validations/validators/format.rb', line 5

def self.validate(model, attribute, value, options)
  return if value.blank?

  unless options.is_a?(Hash)
    options = {
      :with => options,
    }
  end

  unless value.to_s =~ options[:with]
    model.errors.add(attribute, options[:message] || "ungültiges Format")
  end
end