<commit_before>module Forms
  class ApplicationDetail
    include Virtus.model(nullify_blank: true)

    include ActiveModel::Model

    PERMITTED_ATTRIBUTES = { fee: Integer,
                             jurisdiction_id: Integer,
                             date_received: Date,
                             probate: Boolean,
                             date_of_death: Date,
                             deceased_name: String,
                             refund: Boolean,
                             date_fee_paid: Date,
                             form_name: String,
                             case_number: String }


    PERMITTED_ATTRIBUTES.each { |attr, type| attribute attr, type }

    def initialize(object)
      attrs = extract_params(object)
      super(attrs)
    end

    validates :fee, numericality: { allow_blank: true }
    validates :fee, presence: true
    validates :jurisdiction_id, presence: true

    validates :date_received, date: {
      after: proc { Time.zone.today - 3.months },
      before: proc { Time.zone.today + 1.day }
    }

    with_options if: :probate? do
      validates :deceased_name, presence: true
      validates :date_of_death, date: {
                  after: proc { Time.zone.today - 3.months },
                  before: proc { Time.zone.today + 1.day } }<commit_msg>Added time limit for probate<commit_after>module Forms
  class ApplicationDetail
    include Virtus.model(nullify_blank: true)

    include ActiveModel::Model

    TIME_LIMIT_FOR_PROBATE = 20

    PERMITTED_ATTRIBUTES = { fee: Integer,
                             jurisdiction_id: Integer,
                             date_received: Date,
                             probate: Boolean,
                             date_of_death: Date,
                             deceased_name: String,
                             refund: Boolean,
                             date_fee_paid: Date,
                             form_name: String,
                             case_number: String }

    PERMITTED_ATTRIBUTES.each { |attr, type| attribute attr, type }

    def initialize(object)
      attrs = extract_params(object)
      super(attrs)
    end

    validates :fee, numericality: { allow_blank: true }
    validates :fee, presence: true
    validates :jurisdiction_id, presence: true

    validates :date_received, date: {
      after: proc { Time.zone.today - 3.months },
      before: proc { Time.zone.today + 1.day }
    }

    with_options if: :probate? do
      validates :deceased_name, presence: true
      validates :date_of_death, date: {
        after: proc { Time.zone.today - TIME_LIMIT_FOR_PROBATE.years },
        before: proc { Time.zone.today + 1.day }
      }
{'fraction_non_alphanumeric': 0.07663828211773417, 'fraction_numerical': 0.0033320992225101815, 'mean_word_length': 1.6284046692607004, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7305016', 'n_tokens_mistral': 776, 'n_tokens_neox': 726, 'n_words': 176}