5 # validation method to be included like any other validations methods
6 # in the models definitions. this one checks that the named attribute
7 # is a valid UTF-8 format string.
8 def validates_as_utf8(*attrs)
9 validates_each(attrs) do |record, attr, value|
10 record.errors.add(attr, " is invalid UTF-8") unless UTF8.valid? value