mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
refactor Topic validation
introduce a couple of custom validators fix minor discrepancies in tests copy I18n error message keys to default location clean up validation invocation move some responsibilities out of validator into class
This commit is contained in:
9
lib/validators/quality_title_validator.rb
Normal file
9
lib/validators/quality_title_validator.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
require 'text_sentinel'
|
||||
require 'text_cleaner'
|
||||
|
||||
class QualityTitleValidator < ActiveModel::EachValidator
|
||||
def validate_each(record, attribute, value)
|
||||
sentinel = TextSentinel.title_sentinel(value)
|
||||
record.errors.add(attribute, :is_invalid) unless sentinel.valid?
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user