]> git.openstreetmap.org Git - rails.git/blob - lib/validators.rb
Set fixture class when using gpx_files
[rails.git] / lib / validators.rb
1 module ActiveRecord
2   module Validations
3     module ClassMethods
4       ##
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
11         end
12       end
13     end
14   end
15 end