Require display names to have a minimum unicode width of 3 columns

Fixes #4538
This commit is contained in:
Tom Hughes 2024-02-25 13:16:40 +00:00
parent a1a6c577e8
commit 3360f91733
6 changed files with 30 additions and 2 deletions

View 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