Class: ActiveSchema::Validations::ByNullability

Inherits:
ByColumn show all
Defined in:
lib/active_schema/validations/by_column.rb

Instance Method Summary collapse

Methods inherited from ByColumn

#initialize, #validation

Methods inherited from ValueGenerator

#initialize, #validation

Constructor Details

This class inherits a constructor from ActiveSchema::Validations::ByColumn

Instance Method Details

#generateObject



30
31
32
33
34
35
36
37
38
# File 'lib/active_schema/validations/by_column.rb', line 30

def generate
  if not @column.null
    if @column.type == :boolean
      validation :validates_inclusion_of, :in => [true, false]
    else
      validation :validates_presence_of
    end
  end
end