<commit_before>module SUNAT

  # Use ActiveModel Validations so that complex models can be
  # validated before generating a declaration document.
  module Validations
    extend ActiveSupport::Concern
    include ActiveModel::Validations

    # Determine if the model is valid.
    #
    # SUNAT Models are not designed for perisistance, so the context
    # is always assumed to be "create".
    def valid?(*args)
      super(:create)
    end

    module ClassMethods
      # Here we should add support for validating casted models
    end

  end
end

# Add custom validators here to allow it to be used from any model
# allowing everty validator which extends from EachValidator
# to be used with the validates method.
# 
# validates :field, existence: true #=> ExistenceValidator
# 
module ActiveModel
  module Validations
    
    # Tests if not nil. The default PresenceValidator only tests string emptyness.
    class ExistenceValidator < ActiveModel::EachValidator
      def validate_each(record, attribute, value)
        record.errors.add attribute, (options[:message] || "doesn't exist.") if value.nil?
      end
    end
    
    # Tests if not empty. The LengthValidator only works with Strings
    class NotEmptyValidator < ActiveModel::EachValidator
      def validate_each(record, attribute, value)        
        if !value.nil? and value.any?
          messae = (options[:message] || "should have at least one member.")
          record.errors.add attribute, messae
        end
      end
    end
    
    class SunatDocumentValidator < ActiveModel::EachValidator
      SUNAT_CHARACTERS_SIZE = 11
      <commit_msg>fixed some typos<commit_after>module SUNAT

  # Use ActiveModel Validations so that complex models can be
  # validated before generating a declaration document.
  module Validations
    extend ActiveSupport::Concern
    include ActiveModel::Validations

    # Determine if the model is valid.
    #
    # SUNAT Models are not designed for perisistance, so the context
    # is always assumed to be "create".
    def valid?(*args)
      super(:create)
    end

    module ClassMethods
      # Here we should add support for validating casted models
    end

  end
end

# Add custom validators here to allow it to be used from any model,
# allowing every validator which extends from EachValidator
# to be used with the validates method.
# 
# validates :field, existence: true #=> ExistenceValidator
# 
module ActiveModel
  module Validations
    
    # Tests if not nil. The default PresenceValidator only tests string emptyness.
    class ExistenceValidator < ActiveModel::EachValidator
      def validate_each(record, attribute, value)
        record.errors.add attribute, (options[:message] || "doesn't exist.") if value.nil?
      end
    end
    
    # Tests if not empty. The LengthValidator only works with Strings
    class NotEmptyValidator < ActiveModel::EachValidator
      def validate_each(record, attribute, value)        
        if !value.nil? and value.any?
          message = (options[:message] || "should have at least one member.")
          record.errors.add attribute, message
        end
      end
    end
    
    class SunatDocumentValidator < ActiveModel::EachValidator
      SUNAT_CHARACTERS_SIZE = 11
      
{'fraction_non_alphanumeric': 0.060299969390878484, 'fraction_numerical': 0.001224364860728497, 'mean_word_length': 3.019680196801968, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '5797607', 'n_tokens_mistral': 860, 'n_tokens_neox': 829, 'n_words': 334}