Sha256: 02aa26f67247732bb18064147339d6834b1c949ec0baa897a4df572d25bdad4b
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
module Comable class Order < ActiveRecord::Base module Validations extend ActiveSupport::Concern included do validates :user_id, uniqueness: { scope: :completed_at }, if: :user validates :guest_token, presence: true, uniqueness: { scope: :completed_at }, unless: :user with_options if: -> { stated?(:cart) } do |context| context.validates :email, presence: true, length: { maximum: 255 } end with_options if: -> { stated?(:orderer) } do |context| context.validates :bill_address, presence: true end with_options if: -> { stated?(:delivery) } do |context| context.validates :ship_address, presence: true end with_options if: -> { stated?(:shipment) && shipment_required? } do |context| context.validates :shipments, presence: true end with_options if: -> { stated?(:payment) && payment_required? } do |context| context.validates :payment, presence: true end with_options if: -> { stated?(:confirm) } do |context| context.validates :code, presence: true context.validates :payment_fee, presence: true context.validates :shipment_fee, presence: true context.validates :total_price, presence: true end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
comable-core-0.7.0.beta2 | app/models/comable/order/validations.rb |