mirror of
https://github.com/neocities/neocities.git
synced 2025-08-04 16:51:36 +02:00
Start on validations for front create
This commit is contained in:
parent
f13a484e76
commit
2f0380cd4e
3 changed files with 42 additions and 11 deletions
|
@ -646,13 +646,15 @@ class Site < Sequel::Model
|
|||
errors.add :username, 'A valid user/site name is required.'
|
||||
end
|
||||
|
||||
# TODO regex fails for usernames <= 2 chars, tempfix for now.
|
||||
if new? && values[:username].length > 2 && !values[:username].match(VALID_HOSTNAME)
|
||||
errors.add :username, 'A valid user/site name is required.'
|
||||
end
|
||||
if new? && !values[:username].nil? && !values[:username].empty?
|
||||
# TODO regex fails for usernames <= 2 chars, tempfix for now.
|
||||
if new? && values[:username].nil? || (values[:username].length > 2 && !values[:username].match(VALID_HOSTNAME))
|
||||
errors.add :username, 'A valid user/site name is required.'
|
||||
end
|
||||
|
||||
if values[:username].length > 32
|
||||
errors.add :username, 'User/site name cannot exceed 32 characters.'
|
||||
if values[:username].length > 32
|
||||
errors.add :username, 'User/site name cannot exceed 32 characters.'
|
||||
end
|
||||
end
|
||||
|
||||
# Check that email has been provided
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue