summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-10-07 20:09:00 +0200
committerAzul <azul@leap.se>2012-10-07 20:09:00 +0200
commit2215250a39162f9e1fcb8f90e02a637faa63438c (patch)
treeb9ab1fd90e508de0d876b5abcf1acca9d5efeaf6
parent4abbb521c0a23f90a7790db20b281df3f062f4f9 (diff)
added validations
-rw-r--r--users/app/models/user.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/users/app/models/user.rb b/users/app/models/user.rb
index a6aab84..e10f55e 100644
--- a/users/app/models/user.rb
+++ b/users/app/models/user.rb
@@ -5,8 +5,17 @@ class User < CouchRest::Model::Base
property :password_verifier, String, :accessible => true
property :password_salt, String, :accessible => true
- validates :login, :password_salt, :password_verifier, :presence => true
- validates :login, :uniqueness => true
+ validates :login, :password_salt, :password_verifier,
+ :presence => true
+
+ validates :login,
+ :uniqueness => true,
+ :format => { :with => /\A\w+\z/,
+ :message => "Only letters, digits and _ allowed" }
+
+ validates :password_salt, :password_verifier,
+ :format => { :with => /\A[\dA-Fa-f]+\z/,
+ :message => "Only hex numbers allowed" }
timestamps!