<commit_before>module Stripe
  module Plans
    include ConfigurationBuilder

    configuration_for :plan do
      attr_accessor :active,
                    :aggregate_usage,
                    :amount,
                    :billing_scheme,
                    :constant_name,
                    :currency,
                    :interval,
                    :interval_count,
                    :metadata,
                    :name,
                    :nickname,
                    :product_id,
                    :statement_descriptor,
                    :tiers,
                    :tiers_mode,
                    :trial_period_days,
                    :usage_type

      validates_presence_of :id, :amount, :currency

      validates_inclusion_of  :interval,
                              in: %w(day week month year),
                              message: "'%{value}' is not one of 'day', 'week', 'month' or 'year'"

      validates :statement_descriptor, length: { maximum: 22 }

      validates :active,          inclusion: { in: [true, false] }, allow_nil: true
      validates :usage_type,      inclusion: { in: %w{ metered licensed } }, allow_nil: true
      validates :billing_scheme,  inclusion: { in: %w{ per_unit tiered } }, allow_nil: true
      validates :aggregate_usage, inclusion: { in: %w{ sum last_during_period last_ever max } }, allow_nil: true<commit_msg>conditionally validate presence of :amount<commit_after>module Stripe
  module Plans
    include ConfigurationBuilder

    configuration_for :plan do
      attr_accessor :active,
                    :aggregate_usage,
                    :amount,
                    :billing_scheme,
                    :constant_name,
                    :currency,
                    :interval,
                    :interval_count,
                    :metadata,
                    :name,
                    :nickname,
                    :product_id,
                    :statement_descriptor,
                    :tiers,
                    :tiers_mode,
                    :trial_period_days,
                    :usage_type

      validates_presence_of :id, :currency
      validates_presence_of :amount, unless: ->(p) { p.billing_scheme == 'tiered' }

      validates_inclusion_of  :interval,
                              in: %w(day week month year),
                              message: "'%{value}' is not one of 'day', 'week', 'month' or 'year'"

      validates :statement_descriptor, length: { maximum: 22 }

      validates :active,          inclusion: { in: [true, false] }, allow_nil: true
      validates :usage_type,      inclusion: { in: %w{ metered licensed } }, allow_nil: true
      validates :billing_scheme,  inclusion: { in: %w{ per_unit tiered } }, allow_nil: true
      validates :aggregate_usage, inclusion: { in: %w{ sum last_during_period last_ever max } }, allow_nil: true
{'fraction_non_alphanumeric': 0.08588317107093185, 'fraction_numerical': 0.0013908205841446453, 'mean_word_length': 1.5126637554585154, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7515282', 'n_tokens_mistral': 784, 'n_tokens_neox': 730, 'n_words': 190}