Class: UrlNameValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/validations/url_name_validator.rb

Overview

zhe800 url_name validator

Constant Summary collapse

REGEXP =
/^\w+_\d+$/

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



4
5
6
# File 'lib/validations/url_name_validator.rb', line 4

def validate_each(record, attribute, value)
  record.errors.add attribute, (options[:message] || I18n.t('rails_validation.url_name.invalid')) unless value =~ REGEXP
end