Create invalid_char validators and apply to models
This commit is contained in:
parent
64816e50b5
commit
c2f23fea6a
25 changed files with 91 additions and 60 deletions
7
app/validators/trailing_whitespace_validator.rb
Normal file
7
app/validators/trailing_whitespace_validator.rb
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue