X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/a6b84a0294a2929006ff056f56103be549c5b5a2..57a9c0d4fab157aaa5526d60d9026774cb828247:/lib/validators.rb diff --git a/lib/validators.rb b/lib/validators.rb index 69cabb942..0c6b3f594 100644 --- a/lib/validators.rb +++ b/lib/validators.rb @@ -1,15 +1,9 @@ -module ActiveRecord - module Validations - module ClassMethods - ## - # validation method to be included like any other validations methods - # in the models definitions. this one checks that the named attribute - # is a valid UTF-8 format string. - def validates_as_utf8(*attrs) - validates_each(attrs) do |record, attr, value| - record.errors.add(attr, " is invalid UTF-8") unless UTF8.valid? value - end - end - end +## +# validation method to be included like any other validations methods +# in the models definitions. this one checks that the named attribute +# is a valid UTF-8 format string. +class Utf8Validator < ActiveModel::EachValidator + def validate_each(record, attribute, value) + record.errors.add(attribute, " is invalid UTF-8") unless UTF8.valid? value end end