]> git.openstreetmap.org Git - rails.git/blobdiff - app/validators/image_validator.rb
Validate avatar images
[rails.git] / app / validators / image_validator.rb
diff --git a/app/validators/image_validator.rb b/app/validators/image_validator.rb
new file mode 100644 (file)
index 0000000..5aad717
--- /dev/null
@@ -0,0 +1,5 @@
+class ImageValidator < ActiveModel::EachValidator
+  def validate_each(record, attribute, value)
+    record.errors.add(attribute, " must be an image") unless value.image?
+  end
+end