]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/note_comment.rb
Localisation updates from https://translatewiki.net.
[rails.git] / app / models / note_comment.rb
index 07d43cd741da065ada41e4705b458874f5ca3756..31ee6f99b58de4db11862c9c7a258051da134a5b 100644 (file)
@@ -2,16 +2,16 @@ class NoteComment < ActiveRecord::Base
   belongs_to :note, :foreign_key => :note_id, :touch => true
   belongs_to :author, :class_name => "User", :foreign_key => :author_id
 
-  validates_presence_of :id, :on => :update
-  validates_uniqueness_of :id
-  validates_presence_of :note_id
-  validates_associated :note
-  validates_presence_of :visible
-  validates_associated :author
-  validates_inclusion_of :event, :in => [ "opened", "closed", "reopened", "commented", "hidden" ]
+  validates :id, :uniqueness => true, :presence => { :on => :update },
+                 :numericality => { :on => :update, :integer_only => true }
+  validates :note, :presence => true, :associated => true
+  validates :visible, :inclusion => [true, false]
+  validates :author, :associated => true
+  validates :event, :inclusion => %w(opened closed reopened commented hidden)
+  validates :body, :format => /\A[^\x00-\x08\x0b-\x0c\x0e-\x1f\x7f\ufffe\uffff]*\z/
 
   # Return the comment text
   def body
-    RichText.new("text", read_attribute(:body))
+    RichText.new("text", self[:body])
   end
 end