Method: AdvancedBilling::PendingCancellationChange.validate

Defined in:
lib/advanced_billing/models/pending_cancellation_change.rb

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/advanced_billing/models/pending_cancellation_change.rb', line 75

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.cancellation_state,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.cancels_at,
                              ->(val) { val.instance_of? DateTime })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['cancellation_state'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['cancels_at'],
                            ->(val) { val.instance_of? String })
  )
end