Sha256: f52e4ecaa52e172ed4069bbfaba5784e787875d0b4fad60c37507051859ba403

Contents?: true

Size: 495 Bytes

Versions: 1

Compression:

Stored size: 495 Bytes

Contents

module Valle
  class ValidationSetter
    class << self

      ##
      # Adds validator to the klass column depending on its type
      #
      # @param [Bound] bound the bound
      # @param [Column] column the column
      # @param [ActiveRecord::Base] klass the AR model class
      #
      def add_validator(bound, column, klass)
        case column.type
        when :string
          klass.validates column.name, length: { maximum: bound.maximum }
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
valle-0.0.1 lib/valle/validation_setter.rb