]> git.openstreetmap.org Git - rails.git/blob - app/validators/width_validator.rb
Merge remote-tracking branch 'upstream/pull/4977'
[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