Sha256: 9110a48c7a4e47dc81b15f9bc8cd66949284c069192a4744bcf401f4fd9ab2c2

Contents?: true

Size: 701 Bytes

Versions: 8

Compression:

Stored size: 701 Bytes

Contents

# encoding: utf-8

module Katello
  module Validators
    class KatelloNameFormatValidator < ActiveModel::EachValidator
      def validate_each(record, attribute, value)
        if value
          NoTrailingSpaceValidator.validate_trailing_space(record, attribute, value)
          KatelloNameFormatValidator.validate_length(record, attribute, value)
        else
          record.errors[attribute] << N_("cannot be blank")
        end
      end

      def self.validate_length(record, attribute, value, min_length = 1)
        if value && !(value.length >= min_length)
          record.errors[attribute] << _("must contain at least %s character") % min_length
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
katello-4.15.0.rc2 app/lib/katello/validators/katello_name_format_validator.rb
katello-4.15.0.rc1 app/lib/katello/validators/katello_name_format_validator.rb
katello-4.14.1 app/lib/katello/validators/katello_name_format_validator.rb
katello-4.14.0 app/lib/katello/validators/katello_name_format_validator.rb
katello-4.14.0.rc3 app/lib/katello/validators/katello_name_format_validator.rb
katello-4.14.0.rc2 app/lib/katello/validators/katello_name_format_validator.rb
katello-4.14.0.rc1.1 app/lib/katello/validators/katello_name_format_validator.rb
katello-4.14.0.rc1 app/lib/katello/validators/katello_name_format_validator.rb