blob: 830ba30199f5b45b986d8df81a05a1d47c433fa3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# == Schema Information
# Schema version: 114
#
# Table name: contact_validators
#
# name :string
# email :string
# subject :text
# message :text
#
# models/contact_validator.rb:
# Validates contact form submissions.
#
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
class ContactValidator < ActiveRecord::BaseWithoutTable
strip_attributes!
column :name, :string
column :email, :string
column :subject, :text
column :message, :text
validates_presence_of :name, :message => N_("Please enter your name")
validates_presence_of :email, :message => N_("Please enter your email address")
validates_presence_of :subject, :message => N_("Please enter a subject")
validates_presence_of :message, :message => N_("Please enter the message you want to send")
validate :email_format
private
def email_format
errors.add(:email, _("Email doesn't look like a valid address")) unless MySociety::Validate.is_valid_email(self.email)
end
end
|