You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: checks_attribute_values_and_length.rb
    path of file: ./repos/zammad/app/models/application_model
    
    the code of the file until where you have to start completion: # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/

module ApplicationModel::ChecksAttributeValuesAndLength
  extend ActiveSupport::Concern

  included do
    before_create :check_attribute_values_and_length
    before_update :check_attribute_values_and_length
  end

=beg
    
  def check_attribute_values_and_length
    columns = self.class.columns_hash
    attributes.each do |name, value|
      next if !value.instance_of?(String)

      column = columns[name]
      next if !column

      if column.type == :binary
        self[name].force_encoding('BINARY')
      end

      next if value.blank?

      # strip null byte chars (postgresql will complain about it)
      if column.type == :text && Rails.application.config.db_null_byte == false
        self[name].delete!("\u0000")
      end