validates_presence_of :name, :field_format
validates_uniqueness_of :name, :scope => :type
validates_length_of :name, :maximum => 30
- validates_format_of :name, :with => /^[\w\s\.\'\-]*$/i
validates_inclusion_of :field_format, :in => Redmine::CustomFieldFormat.available_formats
def initialize(attributes = nil)
validates_presence_of :name
validates_uniqueness_of :name
validates_length_of :name, :maximum => 30
- validates_format_of :name, :with => /^[\w\s\'\-]*$/i
validates_inclusion_of :default_done_ratio, :in => 0..100, :allow_nil => true
def after_save
validates_presence_of :name
validates_uniqueness_of :name
validates_length_of :name, :maximum => 30
- validates_format_of :name, :with => /^[\w\s\'\-]*$/i
def permissions
read_attribute(:permissions) || []
validates_presence_of :name
validates_uniqueness_of :name
validates_length_of :name, :maximum => 30
- validates_format_of :name, :with => /^[\w\s\'\-]*$/i
def to_s; name end
# Login must contain lettres, numbers, underscores only
validates_format_of :login, :with => /^[a-z0-9_\-@\.]*$/i
validates_length_of :login, :maximum => 30
- validates_format_of :firstname, :lastname, :with => /^[\w\s\'\-\.]*$/i
validates_length_of :firstname, :lastname, :maximum => 30
validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :allow_nil => true
validates_length_of :mail, :maximum => 60, :allow_nil => true
\r
def firstname\r
@firstname = realname.blank? ? username : realname.split.first[0..29]\r
- @firstname.gsub!(/[^\w\s\'\-]/i, '')\r
@firstname\r
end\r
\r
def lastname\r
@lastname = realname.blank? ? '-' : realname.split[1..-1].join(' ')[0..29]\r
- @lastname.gsub!(/[^\w\s\'\-]/i, '')\r
@lastname = '-' if @lastname.blank?\r
@lastname\r
end\r
end\r
\r
def name\r
- read_attribute(:name)[0..29].gsub(/[^\w\s\'\-]/, '-')\r
+ read_attribute(:name)[0..29]\r
end\r
end\r
\r
ln = ($2 || '-').strip
u = User.new :mail => mail.gsub(/[^-@a-z0-9\.]/i, '-'),
- :firstname => fn[0, limit_for(User, 'firstname')].gsub(/[^\w\s\'\-]/i, '-'),
- :lastname => ln[0, limit_for(User, 'lastname')].gsub(/[^\w\s\'\-]/i, '-')
+ :firstname => fn[0, limit_for(User, 'firstname')],
+ :lastname => ln[0, limit_for(User, 'lastname')]
u.login = username[0,limit_for(User, 'login')].gsub(/[^a-z0-9_\-@\.]/i, '-')
u.password = 'trac'