Class: SlugValidator::BrowsePageValidator

Inherits:
InstanceValidator show all
Defined in:
app/validators/slug_validator.rb

Instance Method Summary collapse

Methods inherited from InstanceValidator

#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

Returns:

  • (Boolean)


218
219
220
# File 'app/validators/slug_validator.rb', line 218

def applicable?
  of_kind?('specialist_sector')
end

#validate!Object



222
223
224
225
226
227
228
229
# File 'app/validators/slug_validator.rb', line 222

def validate!
  unless [1, 2].include?(url_parts.size)
    record.errors[attribute] << "must contains one or two path parts"
  end
  unless url_parts.all? { |url_part| valid_slug?(url_part) }
    record.errors[attribute] << "must be usable in a URL"
  end
end