]> git.openstreetmap.org Git - rails.git/blob - app/validators/width_validator.rb
Move current element actions to their own controllers
[rails.git] / app / validators / width_validator.rb
1 class WidthValidator < ActiveModel::Validations::LengthValidator
2   module WidthAsLength
3     def length
4       Unicode::DisplayWidth.of(to_s)
5     end
6   end
7
8   def validate_each(record, attribute, value)
9     super(record, attribute, value.extend(WidthAsLength))
10   end
11 end