<commit_before>class StringzValidator < ActiveModel::EachValidator
    def self.null_char_with_trailing_char_regex
      /\0(.|\n)/
    end

    def validate_each(record, attribute, value)
        if value
            bad_null = value.match StringzValidator.null_char_with_trailing_char_regex
            if bad_null
                record.errors[attribute] = "Attribute #{attribute} has a null terminator in the middle of the string. Sent messages will parse wrong"
            end
        end
    end
end
<commit_msg>Multiple trailing nulls are valid.<commit_after>class StringzValidator < ActiveModel::EachValidator
    def self.null_char_with_trailing_char_regex
      /\0[^\0]/
    end

    def validate_each(record, attribute, value)
        if value
            bad_null = value.match StringzValidator.null_char_with_trailing_char_regex
            if bad_null
                record.errors[attribute] = "Attribute #{attribute} has a null terminator in the middle of the string. Sent messages will parse wrong"
            end
        end
    end
end
{'fraction_non_alphanumeric': 0.06054872280037843, 'fraction_numerical': 0.002838221381267739, 'mean_word_length': 2.6232876712328768, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1748547', 'n_tokens_mistral': 290, 'n_tokens_neox': 280, 'n_words': 84}