27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/sinatra/simple_authentication/models/datamapper/adapter.rb', line 27
def set_validation_rules
validates_presence_of :email, :message => self.settings.error_messages[:missing_email]
validates_uniqueness_of :email, :message => self.settings.error_messages[:taken_email]
validates_format_of :email, :as => :email_address, :message => self.settings.error_messages[:invalid_email]
if Proc.new { |t| t.new_record? }
validates_presence_of :password, :message => self.settings.error_messages[:missing_password]
validates_length_of :password, :min => self.settings.min_password_length, :message => self.settings.error_messages[:short_password]
validates_length_of :password, :max => self.settings.max_password_length, :message => self.settings.error_messages[:long_password]
if self.settings.use_password_confirmation
validates_presence_of :password_confirmation, :message => self.settings.error_messages[:missing_password_confirmation]
end
end
if self.settings.use_password_confirmation
validates_confirmation_of :password, :message => self.settings.error_messages[:password_confirmation_dont_match_password]
end
end
|