INVALID_CHARS = "\x00-\x08\x0b-\x0c\x0e-\x1f\x7f\ufffe\uffff".freeze
def validate_each(record, attribute, value)
- record.errors[attribute] << (options[:message] || "contains invalid chars") if value =~ /[#{INVALID_CHARS}]/
+ record.errors[attribute] << (options[:message] || I18n.t("validations.invalid_chars")) if value =~ /[#{INVALID_CHARS}]/
end
end
INVALID_URL_CHARS = "/;.,?%#".freeze
def validate_each(record, attribute, value)
- record.errors[attribute] << (options[:message] || I18n.t("validations.invalid chars", :invalid_chars => INVALID_URL_CHARS)) if value =~ /[#{INVALID_URL_CHARS}]/
+ record.errors[attribute] << (options[:message] || I18n.t("validations.invalid_url_chars", :invalid_url_chars => INVALID_URL_CHARS)) if value =~ /[#{INVALID_URL_CHARS}]/
end
end
class LeadingWhitespaceValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
- record.errors[attribute] << (options[:message] || I18n.t("validations.leading whitespace")) if value =~ /\A\s/
+ record.errors[attribute] << (options[:message] || I18n.t("validations.leading_whitespace")) if value =~ /\A\s/
end
end
class TrailingWhitespaceValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
- record.errors[attribute] << (options[:message] || I18n.t("validations.trailing whitespace")) if value =~ /\s\z/
+ record.errors[attribute] << (options[:message] || I18n.t("validations.trailing_whitespace")) if value =~ /\s\z/
end
end
flash: "Redaction destroyed."
error: "There was an error destroying this redaction."
validations:
- leading whitespace: "has leading whitespace"
- trailing whitespace: "has trailing whitespace"
- invalid chars: "must not contain an invalid char: %{invalid_chars}"
+ leading_whitespace: "has leading whitespace"
+ trailing_whitespace: "has trailing whitespace"
+ invalid_chars: "contains invalid chars"
+ invalid_url_chars: "must not contain an invalid char: %{invalid_url_chars}"