Class: SlugValidator::SpecialistDocumentPageValidator

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)


190
191
192
# File 'app/validators/slug_validator.rb', line 190

def applicable?
  of_kind?(acceptable_formats)
end

#validate!Object



194
195
196
197
198
199
200
201
# File 'app/validators/slug_validator.rb', line 194

def validate!
  unless url_parts.size == 2
    record.errors[attribute] << "must be of form <finder-slug>/<specialist-document-slug>"
  end
  unless url_parts.all? { |url_part| valid_slug?(url_part) }
    record.errors[attribute] << "must be usable in a URL"
  end
end