Class: EVSS::PCIUAddress::Address

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Serialization, ActiveModel::Validations
Defined in:
lib/evss/pciu_address/address.rb

Overview

Model for PCIU address

Constant Summary collapse

ADDRESS_TYPES =
{
  domestic: 'DOMESTIC',
  international: 'INTERNATIONAL',
  military: 'MILITARY'
}.freeze
ZIP_CODE_REGEX =
/\A\d{5}\z/
ZIP_SUFFIX_REGEX =
/\A-?\d{4}\z/

Instance Attribute Summary collapse

Instance Attribute Details

#address_effective_dateDateTime

Returns The date at which the address is known to be valid.

Returns:

  • (DateTime)

    The date at which the address is known to be valid



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/evss/pciu_address/address.rb', line 22

class Address
  include ActiveModel::Validations
  include ActiveModel::Serialization
  include Virtus.model(nullify_blank: true)

  ADDRESS_TYPES = {
    domestic: 'DOMESTIC',
    international: 'INTERNATIONAL',
    military: 'MILITARY'
  }.freeze
  ZIP_CODE_REGEX = /\A\d{5}\z/
  ZIP_SUFFIX_REGEX = /\A-?\d{4}\z/

  attribute :type, String
  attribute :address_effective_date, DateTime
  attribute :address_one, String
  attribute :address_two, String
  attribute :address_three, String

  validates :address_one, pciu_address_line: true, presence: true, length: { maximum: 35 }
  validates :address_two, pciu_address_line: true, length: { maximum: 35 }
  validates :address_three, pciu_address_line: true, length: { maximum: 35 }
  validates :type, inclusion: { in: ADDRESS_TYPES.values }
end

#address_oneString

Returns The first line of the address (max 35 characters).

Returns:

  • (String)

    The first line of the address (max 35 characters)



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/evss/pciu_address/address.rb', line 22

class Address
  include ActiveModel::Validations
  include ActiveModel::Serialization
  include Virtus.model(nullify_blank: true)

  ADDRESS_TYPES = {
    domestic: 'DOMESTIC',
    international: 'INTERNATIONAL',
    military: 'MILITARY'
  }.freeze
  ZIP_CODE_REGEX = /\A\d{5}\z/
  ZIP_SUFFIX_REGEX = /\A-?\d{4}\z/

  attribute :type, String
  attribute :address_effective_date, DateTime
  attribute :address_one, String
  attribute :address_two, String
  attribute :address_three, String

  validates :address_one, pciu_address_line: true, presence: true, length: { maximum: 35 }
  validates :address_two, pciu_address_line: true, length: { maximum: 35 }
  validates :address_three, pciu_address_line: true, length: { maximum: 35 }
  validates :type, inclusion: { in: ADDRESS_TYPES.values }
end

#address_threeString

Returns The third line of the address (max 35 characters).

Returns:

  • (String)

    The third line of the address (max 35 characters)



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/evss/pciu_address/address.rb', line 22

class Address
  include ActiveModel::Validations
  include ActiveModel::Serialization
  include Virtus.model(nullify_blank: true)

  ADDRESS_TYPES = {
    domestic: 'DOMESTIC',
    international: 'INTERNATIONAL',
    military: 'MILITARY'
  }.freeze
  ZIP_CODE_REGEX = /\A\d{5}\z/
  ZIP_SUFFIX_REGEX = /\A-?\d{4}\z/

  attribute :type, String
  attribute :address_effective_date, DateTime
  attribute :address_one, String
  attribute :address_two, String
  attribute :address_three, String

  validates :address_one, pciu_address_line: true, presence: true, length: { maximum: 35 }
  validates :address_two, pciu_address_line: true, length: { maximum: 35 }
  validates :address_three, pciu_address_line: true, length: { maximum: 35 }
  validates :type, inclusion: { in: ADDRESS_TYPES.values }
end

#address_twoString

Returns The second line of the address (max 35 characters).

Returns:

  • (String)

    The second line of the address (max 35 characters)



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/evss/pciu_address/address.rb', line 22

class Address
  include ActiveModel::Validations
  include ActiveModel::Serialization
  include Virtus.model(nullify_blank: true)

  ADDRESS_TYPES = {
    domestic: 'DOMESTIC',
    international: 'INTERNATIONAL',
    military: 'MILITARY'
  }.freeze
  ZIP_CODE_REGEX = /\A\d{5}\z/
  ZIP_SUFFIX_REGEX = /\A-?\d{4}\z/

  attribute :type, String
  attribute :address_effective_date, DateTime
  attribute :address_one, String
  attribute :address_two, String
  attribute :address_three, String

  validates :address_one, pciu_address_line: true, presence: true, length: { maximum: 35 }
  validates :address_two, pciu_address_line: true, length: { maximum: 35 }
  validates :address_three, pciu_address_line: true, length: { maximum: 35 }
  validates :type, inclusion: { in: ADDRESS_TYPES.values }
end

#typeString

Returns Address type; one of %w[DOMESTIC INTERNATIONAL MILITARY].

Returns:

  • (String)

    Address type; one of %w[DOMESTIC INTERNATIONAL MILITARY]



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/evss/pciu_address/address.rb', line 22

class Address
  include ActiveModel::Validations
  include ActiveModel::Serialization
  include Virtus.model(nullify_blank: true)

  ADDRESS_TYPES = {
    domestic: 'DOMESTIC',
    international: 'INTERNATIONAL',
    military: 'MILITARY'
  }.freeze
  ZIP_CODE_REGEX = /\A\d{5}\z/
  ZIP_SUFFIX_REGEX = /\A-?\d{4}\z/

  attribute :type, String
  attribute :address_effective_date, DateTime
  attribute :address_one, String
  attribute :address_two, String
  attribute :address_three, String

  validates :address_one, pciu_address_line: true, presence: true, length: { maximum: 35 }
  validates :address_two, pciu_address_line: true, length: { maximum: 35 }
  validates :address_three, pciu_address_line: true, length: { maximum: 35 }
  validates :type, inclusion: { in: ADDRESS_TYPES.values }
end