Class: AvalaraSdk::A1099::V2::W8BenEFormRequest::EnumAttributeValidator

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(datatype, allowable_values) ⇒ EnumAttributeValidator

Returns a new instance of EnumAttributeValidator.



321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/avalara_sdk/models/A1099/V2/w8_ben_e_form_request.rb', line 321

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.



319
320
321
# File 'lib/avalara_sdk/models/A1099/V2/w8_ben_e_form_request.rb', line 319

def allowable_values
  @allowable_values
end

#datatypeObject (readonly)

Returns the value of attribute datatype.



318
319
320
# File 'lib/avalara_sdk/models/A1099/V2/w8_ben_e_form_request.rb', line 318

def datatype
  @datatype
end

Instance Method Details

#valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


334
335
336
# File 'lib/avalara_sdk/models/A1099/V2/w8_ben_e_form_request.rb', line 334

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