diff options
Diffstat (limited to 'users/app/models')
| -rw-r--r-- | users/app/models/email.rb | 8 | ||||
| -rw-r--r-- | users/app/models/identity.rb | 6 | 
2 files changed, 13 insertions, 1 deletions
diff --git a/users/app/models/email.rb b/users/app/models/email.rb index 89c31bb..f38f2f5 100644 --- a/users/app/models/email.rb +++ b/users/app/models/email.rb @@ -3,10 +3,16 @@ class Email < String    validates :email,      :format => { -      :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/, +      :with => /\A([^@\s]+)@((?:[-a-zA-Z0-9]+\.)+[a-zA-Z]{2,})\Z/, #checks format, but allows lowercase        :message => "needs to be a valid email address"      } +  validates :email, +    :format => { +      :with => /\A[^A-Z]*\Z/, #forbids uppercase characters +      :message => "letters must be lowercase" +    } +    def to_partial_path      "emails/email"    end diff --git a/users/app/models/identity.rb b/users/app/models/identity.rb index 91345a0..e0a24e9 100644 --- a/users/app/models/identity.rb +++ b/users/app/models/identity.rb @@ -12,6 +12,7 @@ class Identity < CouchRest::Model::Base    validate :unique_forward    validate :alias_available    validate :address_local_email +  validate :destination_email    design do      view :by_user_id @@ -91,4 +92,9 @@ class Identity < CouchRest::Model::Base      self.errors.add(:address, address.errors.messages[:email].first) #assumes only one error    end +  def destination_email +    return if destination.valid? #this ensures it is Email +    self.errors.add(:destination, destination.errors.messages[:email].first) #assumes only one error #TODO +  end +  end  | 
