Create invalid_char validators and apply to models

This commit is contained in:
J Guthrie 2018-11-04 18:28:27 +00:00
parent 64816e50b5
commit c2f23fea6a
25 changed files with 91 additions and 60 deletions

View file

@ -0,0 +1,7 @@
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
end
end