Class: Ea::Validation::CompaniesHouseNameValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- Ea::Validation::CompaniesHouseNameValidator
- Defined in:
- lib/ea/validation/companies_house_name_validator.rb
Constant Summary collapse
- VALID_COMPANIES_HOUSE_NAME_REGEX =
Regexp.new(/[\^|_~¬`]/).freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.disallowed_chars ⇒ Object
28 29 30 |
# File 'lib/ea/validation/companies_house_name_validator.rb', line 28 def self.disallowed_chars @disallowed_chars ||= ["^", "|", "_", "~", "¬", "`"] end |
.name_max_length ⇒ Object
24 25 26 |
# File 'lib/ea/validation/companies_house_name_validator.rb', line 24 def self.name_max_length 170 end |
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/ea/validation/companies_house_name_validator.rb', line 15 def validate_each(record, attribute, value) if VALID_COMPANIES_HOUSE_NAME_REGEX.match(value) record.errors.add( attribute, ([:message] || I18n.t("ea.validation.errors.companies_house_name.#{attribute}.invalid")) ) end end |