mirror of
https://github.com/neocities/neocities.git
synced 2025-08-05 17:18:02 +02:00
fix tags validation on create
This commit is contained in:
parent
134790dcbc
commit
66fdbab21e
3 changed files with 7 additions and 7 deletions
|
@ -762,28 +762,28 @@ class Site < Sequel::Model
|
|||
@new_filtered_tags = []
|
||||
|
||||
if ((new? ? 0 : tags_dataset.count) + new_tags.length > 5)
|
||||
errors.add :tags, 'Cannot have more than 5 tags for your site.'
|
||||
errors.add :new_tags_string, 'Cannot have more than 5 tags for your site.'
|
||||
end
|
||||
|
||||
new_tags.each do |tag|
|
||||
tag.strip!
|
||||
if tag.match(/[^a-zA-Z0-9 ]/)
|
||||
errors.add :tags, "Tag \"#{tag}\" can only contain letters (A-Z) and numbers (0-9)."
|
||||
errors.add :new_tags_string, "Tag \"#{tag}\" can only contain letters (A-Z) and numbers (0-9)."
|
||||
break
|
||||
end
|
||||
|
||||
if tag.length > Tag::NAME_LENGTH_MAX
|
||||
errors.add :tags, "Tag \"#{tag}\" cannot be longer than #{Tag::NAME_LENGTH_MAX} characters."
|
||||
errors.add :new_tags_string, "Tag \"#{tag}\" cannot be longer than #{Tag::NAME_LENGTH_MAX} characters."
|
||||
break
|
||||
end
|
||||
|
||||
if tag.match(/ /)
|
||||
errors.add :tags, "Tag \"#{tag}\" cannot have spaces."
|
||||
errors.add :new_tags_string, "Tag \"#{tag}\" cannot have spaces."
|
||||
break
|
||||
end
|
||||
|
||||
if tag.split(' ').length > Tag::NAME_WORDS_MAX
|
||||
errors.add :tags, "Tag \"#{tag}\" cannot be more than #{Tag::NAME_WORDS_MAX} word."
|
||||
errors.add :new_tags_string, "Tag \"#{tag}\" cannot be more than #{Tag::NAME_WORDS_MAX} word."
|
||||
break
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue