]> git.openstreetmap.org Git - rails.git/blob - app/validators/width_validator.rb
Add frozen_string_literal comments to ruby files
[rails.git] / app / validators / width_validator.rb
1 # frozen_string_literal: true
2
3 class WidthValidator < ActiveModel::Validations::LengthValidator
4   module WidthAsLength
5     def length
6       Unicode::DisplayWidth.of(to_s)
7     end
8   end
9
10   def validate_each(record, attribute, value)
11     super(record, attribute, value.extend(WidthAsLength))
12   end
13 end