mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-04 21:15:19 +02:00
11 lines
499 B
Ruby
11 lines
499 B
Ruby
class Rule::Condition < ApplicationRecord
|
|
OPERATORS = [ "and", "or", "gt", "lt", "eq" ]
|
|
TYPES = [ "match_merchant", "compare_amount", "compound" ]
|
|
|
|
belongs_to :rule, optional: true
|
|
belongs_to :parent, class_name: "Rule::Condition", optional: true
|
|
has_many :conditions, class_name: "Rule::Condition", foreign_key: :parent_id, dependent: :destroy
|
|
|
|
validates :operator, inclusion: { in: OPERATORS }, allow_nil: true
|
|
validates :condition_type, presence: true, inclusion: { in: TYPES }
|
|
end
|