Sha256: 5f58b39062d39103acb66c7d558c320842599c1e18f997134b9d84091f533211

Contents?: true

Size: 586 Bytes

Versions: 3

Compression:

Stored size: 586 Bytes

Contents

module Katello
  module Validators
    class KatelloURLFormatValidator < ActiveModel::EachValidator
      include KatelloURLHelper

      def validate_each(record, attribute, value)
        if options[:nil_allowed]
          if options[:nil_allowed].respond_to?(:call)
            return if value.nil? && options[:nil_allowed].call(record)
          else
            return if value.nil?
          end
        end

        attribute_name = options[:field_name] || attribute
        record.errors[attribute_name] << N_("is invalid") unless kurl_valid?(value)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
katello-4.15.0 app/lib/katello/validators/katello_url_format_validator.rb
katello-4.15.0.rc2 app/lib/katello/validators/katello_url_format_validator.rb
katello-4.15.0.rc1 app/lib/katello/validators/katello_url_format_validator.rb