lib/lite/validators/url_validator.rb in lite-validators-1.7.2 vs lib/lite/validators/url_validator.rb in lite-validators-1.8.0

- old
+ new

@@ -1,8 +1,8 @@ # frozen_string_literal: true -require 'uri' unless defined?(URI) +require "uri" unless defined?(URI) class UrlValidator < BaseValidator SCHEMES = %w[ http https @@ -19,11 +19,10 @@ def error_message_for(option) options[:message] || I18n.t("errors.messages.url.#{option}") end - # rubocop:disable Layout/LineLength, Metrics/AbcSize def valid_attr? raise URI::InvalidURIError if value.to_s.strip.empty? valid_uri? && valid_host? && valid_domain? && valid_scheme? && valid_root? end @@ -51,11 +50,11 @@ end def valid_root? return true unless options[:root_only] - check = ['', '/'].include?(value.path) && value.query.blank? && value.fragment.blank? + check = ["", "/"].include?(value.path) && value.query.blank? && value.fragment.blank? return true if check record.errors.add(attribute, error_message_for(:root)) end @@ -71,8 +70,7 @@ end def valid_uri? value.is_a?(URI::Generic) end - # rubocop:enable Layout/LineLength, Metrics/AbcSize end