Class: CardValidation

Inherits:
Object
  • Object
show all
Defined in:
lib/util/validation/card.rb

Class Method Summary collapse

Class Method Details

.create(data) ⇒ Object



8
9
10
11
# File 'lib/util/validation/card.rb', line 8

def self.create(data)
  HelperValidation.validate_string_start(data[:customer_id], "cus")
  HelperValidation.validate_string_start(data[:token_id], "tkn")
end

.list(data) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/util/validation/card.rb', line 13

def self.list(data)
  # Validate card_brand
  if data.key?('card_brand')
    allowed_brand_values = ['Visa', 'Mastercard', 'Amex', 'Diners']
    Helpers.validate_value(data[:card_brand], allowed_brand_values)
  end

  # Validate card_type
  if data.key?('card_type')
    allowed_card_type_values = ['credito', 'debito', 'internacional']
    Helpers.validate_value(data[:card_type], allowed_card_type_values)
  end

  # Validate date filter
  if data.key?('creation_date_from') && data.key?('creation_date_to')
    Helpers.validate_date_filter(data[:creation_date_from], data[:creation_date_to])
  end

  # Validate country_code
  if data.key?('country_code')
    Helpers.validate_value(data[:country_code], get_country_codes)
  end
end