openstreetmap-website/app/validators/trailing_whitespace_validator.rb
2018-11-05 14:27:06 +00:00

5 lines
235 B
Ruby

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