Validate username. Gitlab::Regex added
This commit is contained in:
parent
5ed4e7e216
commit
47234ab367
8 changed files with 43 additions and 13 deletions
|
@ -19,7 +19,7 @@ class Namespace < ActiveRecord::Base
|
|||
|
||||
validates :name, presence: true, uniqueness: true
|
||||
validates :path, uniqueness: true, presence: true, length: { within: 1..255 },
|
||||
format: { with: /\A[a-zA-Z][a-zA-Z0-9_\-\.]*\z/,
|
||||
format: { with: Gitlab::Regex.path_regex,
|
||||
message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" }
|
||||
validates :owner, presence: true
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ class Project < ActiveRecord::Base
|
|||
validates :description, length: { within: 0..2000 }
|
||||
validates :name, presence: true, length: { within: 0..255 }
|
||||
validates :path, presence: true, length: { within: 0..255 },
|
||||
format: { with: /\A[a-zA-Z][a-zA-Z0-9_\-\.]*\z/,
|
||||
format: { with: Gitlab::Regex.path_regex,
|
||||
message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" }
|
||||
validates :issues_enabled, :wall_enabled, :merge_requests_enabled,
|
||||
:wiki_enabled, inclusion: { in: [true, false] }
|
||||
|
|
|
@ -41,8 +41,8 @@ class User < ActiveRecord::Base
|
|||
|
||||
attr_accessible :email, :password, :password_confirmation, :remember_me, :bio, :name, :username,
|
||||
:skype, :linkedin, :twitter, :dark_scheme, :theme_id, :force_random_password,
|
||||
:extern_uid, :provider, :as => [:default, :admin]
|
||||
attr_accessible :projects_limit, :as => :admin
|
||||
:extern_uid, :provider, as: [:default, :admin]
|
||||
attr_accessible :projects_limit, as: :admin
|
||||
|
||||
attr_accessor :force_random_password
|
||||
|
||||
|
@ -63,9 +63,12 @@ class User < ActiveRecord::Base
|
|||
has_many :assigned_merge_requests, class_name: "MergeRequest", foreign_key: :assignee_id, dependent: :destroy
|
||||
|
||||
validates :bio, length: { within: 0..255 }
|
||||
validates :extern_uid, :allow_blank => true, :uniqueness => {:scope => :provider}
|
||||
validates :extern_uid, allow_blank: true, uniqueness: {scope: :provider}
|
||||
validates :projects_limit, presence: true, numericality: {greater_than_or_equal_to: 0}
|
||||
validates :username, presence: true
|
||||
validates :username, presence: true, uniqueness: true,
|
||||
format: { with: Gitlab::Regex.username_regex,
|
||||
message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" }
|
||||
|
||||
|
||||
before_validation :generate_password, on: :create
|
||||
before_save :ensure_authentication_token
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue