class NotANationalArchivesURLValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    return if value.blank?
    if value.include?('http://webarchive.nationalarchives.gov.uk')
      message = (options[:message])
      record.errors.add(attribute, message)
    end
  end
end

class NotANationalArchivesURLValidator < ActiveModel::EachValidator
  NATIONAL_ARCHIVES_HOST = 'webarchive.nationalarchives.gov.uk'

  def validate_each(record, attribute, value)
    return if value.blank?
    valid_url = begin
      uri = Addressable::URI.parse(value)
      uri.host != NATIONAL_ARCHIVES_HOST
    rescue Addressable::URI::InvalidURIError
      false
    end
    record.errors.add(attribute, options[:message]) unless valid_url
   end
end

Make the not-TNA validator check a parsed URL's host, not just a string
Make the not-TNA validator check a parsed URL's host, not just a string

- This makes it consistent with how NationalArchivesURLValidator checks
  for a TNA host.
