Skip to content

Commit

Permalink
Merge pull request #1197 from codidact/taeir/fix-validations-apply-to…
Browse files Browse the repository at this point in the history
…-help-policy

Skip min title validation for help/policy posts
  • Loading branch information
Taeir authored Nov 12, 2023
2 parents 051adf7 + 4c46487 commit 298b9c8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/models/concerns/post_validations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@ def stripped_minimum_body
end

def stripped_minimum_title
min_title = category.nil? ? 15 : category.min_title_length
min_title = if ['HelpDoc', 'PolicyDoc'].include?(post_type.name)
1
elsif category.nil?
15
else
category.min_title_length
end

if (title&.gsub(/(?:^[\s\t\u2000-\u200F]+|[\s\t\u2000-\u200F]+$)/, '')&.length || 0) < min_title
errors.add(:title, "must be more than #{min_title} non-whitespace characters long")
end
Expand Down

0 comments on commit 298b9c8

Please sign in to comment.