<commit_before>class SlugValidator < ActiveModel::EachValidator
  # implement the method called during validation
  def validate_each(record, attribute, value)
    validators = [
      DonePageValidator,
      ForeignTravelAdvicePageValidator,
      HelpPageValidator,
      GovernmentPageValidator,
      ManualPageValidator,
      SpecialistDocumentPageValidator,
      BrowsePageValidator,
      DefaultValidator
    ].map { |klass| klass.new(record, attribute, value) }

    validators.find(&:applicable?).validate!
  end

protected
  class InstanceValidator < Struct.new(:record, :attribute, :value)
    def starts_with?(expected_prefix)
      value.to_s[0...expected_prefix.size] == expected_prefix
    end<commit_msg>Use String#start_with? to implement starts_with?<commit_after>class SlugValidator < ActiveModel::EachValidator
  # implement the method called during validation
  def validate_each(record, attribute, value)
    validators = [
      DonePageValidator,
      ForeignTravelAdvicePageValidator,
      HelpPageValidator,
      GovernmentPageValidator,
      ManualPageValidator,
      SpecialistDocumentPageValidator,
      BrowsePageValidator,
      DefaultValidator
    ].map { |klass| klass.new(record, attribute, value) }

    validators.find(&:applicable?).validate!
  end

protected
  class InstanceValidator < Struct.new(:record, :attribute, :value)
    def starts_with?(expected_prefix)
      value.to_s.start_with?(expected_prefix)
    end
{'fraction_non_alphanumeric': 0.08111792774369461, 'fraction_numerical': 0.0006816632583503749, 'mean_word_length': 4.205673758865248, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4310164', 'n_tokens_mistral': 397, 'n_tokens_neox': 395, 'n_words': 82}