Class: SlugValidator::DetailedGuideValidator
Instance Method Summary
collapse
#ends_with?, #of_kind?, #starts_with?, #url_after_first_slash, #url_after_first_slash_is_valid_slug!, #url_parts, #valid_slug?
Instance Method Details
#applicable? ⇒ Boolean
151
152
153
|
# File 'app/validators/slug_validator.rb', line 151
def applicable?
of_kind?('detailed_guide')
end
|
#validate! ⇒ Object
155
156
157
|
# File 'app/validators/slug_validator.rb', line 155
def validate!
record.errors[attribute] << "must be a valid URL either at the root or under 'guidance/'" unless value.match(%r{^(guidance/)?[a-z0-9\-_]+$})
end
|