Require display names to have a minimum unicode width of 3 columns
Fixes #4538
This commit is contained in:
parent
a1a6c577e8
commit
3360f91733
6 changed files with 30 additions and 2 deletions
11
app/validators/width_validator.rb
Normal file
11
app/validators/width_validator.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
class WidthValidator < ActiveModel::Validations::LengthValidator
|
||||
module WidthAsLength
|
||||
def length
|
||||
Unicode::DisplayWidth.of(to_s)
|
||||
end
|
||||
end
|
||||
|
||||
def validate_each(record, attribute, value)
|
||||
super(record, attribute, value.extend(WidthAsLength))
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue