Sha256: bf39b4a8bbc4b03af1889a50fb3023aa790c2513e1e4d8109b818b41e310aa3f

Contents?: true

Size: 437 Bytes

Versions: 1

Compression:

Stored size: 437 Bytes

Contents

# frozen_string_literal: true

class Gutentag::TagValidations
  def self.call(klass)
    new(klass).call
  end

  def initialize(klass)
    @klass = klass
  end

  def call
    klass.validates :name,
      :presence   => true,
      :uniqueness => {:case_sensitive => false}

    limit = klass.columns_hash["name"].limit
    klass.validates_length_of :name, :maximum => limit if limit.present?
  end

  private

  attr_reader :klass
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gutentag-1.1.0 lib/gutentag/tag_validations.rb