65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/cortex_reaver/model/comment.rb', line 65
def validate
validates_presence :body
validates_max_length 255, :name, :allow_blank => true
validates_max_length 255, :http, :allow_blank => true
validates_max_length 255, :email, :allow_blank => true
validates_format(/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/, :email, :allow_blank => true)
if (not email.blank?) and User.filter(:email => email).count > 0
self.errors[:email] << 'conflicts with a registered user'
end
count = 0
[:page_id, :journal_id, :comment_id, :photograph_id].each do |field|
unless self[field].blank?
count += 1
if count > 1
self.errors[:comment] << 'has too many kinds of parents'
break
end
end
end
if count == 0
self.errors[:comment] << "doesn't have a parent"
end
end
|