pupilfirst/pupilfirst

View on GitHub
app/validators/urls_validator.rb

Summary

Maintainability
A
0 mins
Test Coverage
F
33%
class UrlsValidator < ActiveModel::Validations::UrlValidator
  def validate_each(record, attribute, values)
    # Unfreeze options, so that we can mess with the message in here.
    @options = @options.dup

    values.each_with_index do |value, index|
      options[:message] = "Link #{index + 1} is invalid"
      super(record, attribute, value)
    end
  end
end