]> git.openstreetmap.org Git - rails.git/blob - app/validators/trailing_whitespace_validator.rb
bb34ef463088e7af104f70caf4415d81a9d5adfe
[rails.git] / app / validators / trailing_whitespace_validator.rb
1 class TrailingWhitespaceValidator < ActiveModel::EachValidator
2   def validate_each(record, attribute, value)
3     if value =~ /\s\z/
4       record.errors[attribute] << (options[:message] || I18n.t("validations.trailing whitespace"))
5     end
6   end
7 end