Class: ActiveSchema::Validations::ByDataType
- Inherits:
-
ByColumn
- Object
- ValueGenerator
- ByColumn
- ActiveSchema::Validations::ByDataType
- Defined in:
- lib/active_schema/validations/by_column.rb
Instance Method Summary collapse
Methods inherited from ByColumn
Methods inherited from ValueGenerator
Constructor Details
This class inherits a constructor from ActiveSchema::Validations::ByColumn
Instance Method Details
#generate ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/active_schema/validations/by_column.rb', line 15 def generate if @column.type == :integer validation :validates_numericality_of, {:allow_nil => true, :only_integer => true} elsif @column.number? validation :validates_numericality_of, {:allow_nil => true} elsif @column.text? && @column.limit validation :validates_length_of, {:allow_nil => true, :maximum => @column.limit} elsif @column.type == :enum # Support MySQL ENUM type as provided by the enum_column plugin validation :validates_inclusion_of, :in => @column.limit end end |