Class: AvalaraSdk::A1099::V2::W8BenEFormResponse::EnumAttributeValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/avalara_sdk/models/A1099/V2/w8_ben_e_form_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(datatype, allowable_values) ⇒ EnumAttributeValidator

Returns a new instance of EnumAttributeValidator.



348
349
350
351
352
353
354
355
356
357
358
359
# File 'lib/avalara_sdk/models/A1099/V2/w8_ben_e_form_response.rb', line 348

def initialize(datatype, allowable_values)
  @allowable_values = allowable_values.map do |value|
    case datatype.to_s
    when /Integer/i
      value.to_i
    when /Float/i
      value.to_f
    else
      value
    end
  end
end

Instance Attribute Details

#allowable_valuesObject (readonly)

Returns the value of attribute allowable_values.



346
347
348
# File 'lib/avalara_sdk/models/A1099/V2/w8_ben_e_form_response.rb', line 346

def allowable_values
  @allowable_values
end

#datatypeObject (readonly)

Returns the value of attribute datatype.



345
346
347
# File 'lib/avalara_sdk/models/A1099/V2/w8_ben_e_form_response.rb', line 345

def datatype
  @datatype
end

Instance Method Details

#valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


361
362
363
# File 'lib/avalara_sdk/models/A1099/V2/w8_ben_e_form_response.rb', line 361

def valid?(value)
  !value || allowable_values.include?(value)
end