Fix rubocop errors

This commit is contained in:
J Guthrie 2018-11-04 18:52:45 +00:00
parent c2f23fea6a
commit 3b68061e87
4 changed files with 8 additions and 16 deletions

View file

@ -2,8 +2,6 @@ class InvalidCharsValidator < ActiveModel::EachValidator
INVALID_CHARS = "\x00-\x08\x0b-\x0c\x0e-\x1f\x7f\ufffe\uffff".freeze
def validate_each(record, attribute, value)
if value =~ /[#{INVALID_CHARS}]/
record.errors[attribute] << (options[:message] || "contains invalid chars")
end
record.errors[attribute] << (options[:message] || "contains invalid chars") if value =~ /[#{INVALID_CHARS}]/
end
end
end

View file

@ -2,8 +2,6 @@ class InvalidUrlCharsValidator < ActiveModel::EachValidator
INVALID_URL_CHARS = "/;.,?%#".freeze
def validate_each(record, attribute, value)
if value =~ /[#{INVALID_URL_CHARS}]/
record.errors[attribute] << (options[:message] || I18n.t("validations.invalid chars", :invalid_chars => INVALID_URL_CHARS))
end
record.errors[attribute] << (options[:message] || I18n.t("validations.invalid chars", :invalid_chars => INVALID_URL_CHARS)) if value =~ /[#{INVALID_URL_CHARS}]/
end
end
end

View file

@ -1,7 +1,5 @@
class LeadingWhitespaceValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
if value =~ /\A\s/
record.errors[attribute] << (options[:message] || I18n.t("validations.leading whitespace"))
end
record.errors[attribute] << (options[:message] || I18n.t("validations.leading whitespace")) if value =~ /\A\s/
end
end
end

View file

@ -1,7 +1,5 @@
class TrailingWhitespaceValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
if value =~ /\s\z/
record.errors[attribute] << (options[:message] || I18n.t("validations.trailing whitespace"))
end
record.errors[attribute] << (options[:message] || I18n.t("validations.trailing whitespace")) if value =~ /\s\z/
end
end
end