Class: EtiquetteValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Includes:
ActionView::Helpers::SanitizeHelper
Defined in:
app/validators/etiquette_validator.rb

Overview

This validator takes care of ensuring the validated content is respectful, does not use caps, and overall is meaningful.

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'app/validators/etiquette_validator.rb', line 8

def validate_each(record, attribute, value)
  return if value.blank?

  text_value = strip_tags(value)

  validate_caps(record, attribute, text_value)
  validate_marks(record, attribute, text_value)
  validate_caps_first(record, attribute, text_value)
end