# File lib/validate_url.rb, line 20
      def validate_each(record, attribute, value)
        schemes = [*options.fetch(:schemes)].map(&:to_s)
        begin
          uri = URI.parse(URI.escape(value))
          host = uri && uri.host
          scheme = uri && uri.scheme

          valid_suffix = !options.fetch(:public_suffix) || (host && PublicSuffix.valid?(host, :default_rule => nil))
          valid_no_local = !options.fetch(:no_local) || (host && host.include?('.'))
          valid_scheme = host && scheme && schemes.include?(scheme)

          unless valid_scheme && valid_no_local && valid_suffix
            record.errors.add(attribute, options.fetch(:message), value: value)
          end
        rescue URI::InvalidURIError
          record.errors.add(attribute, :url, filtered_options(value))
        end
      end