Sha256: 7b11bbf087d273a1b9f4f805d6cc2095397fc9fb46496a0d5d89afa29a6e1faa

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 KB

Contents

module Eddy
  module Elements
    # ### Element Summary:
    #
    # - Id: 116
    # - Name: Postal Code
    # - Type: ID
    # - Min/Max: 3/15
    # - Description: Code defining international postal zone code excluding punctuation and blanks (zip code for United States)
    #
    # ### Notes:
    #
    # - There are too many valid values for this, so it uses a regular expression instead of a codelist.
    # - FIXME: Implement that ☝
    # - See [Segment and Data Element Definitions - X12 RFI](http://www.x12.org/rfis/Segment%20and%20Data%20Element%20Definitions.pdf)
    class E116 < Eddy::Element::AN

      # @param val [String] (nil)
      # @param req [String] (nil)
      # @param ref [String] (nil)
      # @return [void]
      def initialize(val: nil, req: nil, ref: nil)
        @id = "116"
        @name = "Postal Code"
        @description = "Code defining international postal zone code excluding punctuation and blanks (zip code for United States)"
        super(
          min: 3,
          max: 15,
          req: req,
          ref: ref,
          val: val,
        )
      end

      # Matches any valid US zip code.
      #
      # @return [Regexp]
      def pattern
        return /^[0-9]{5}(?:-[0-9]{4})?$/
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
eddy-0.5.1 lib/definitions/elements/manual/116.postal_code.rb
eddy-0.5.0 lib/definitions/elements/manual/116.postal_code.rb
eddy-0.4.0 lib/definitions/elements/manual/116.postal_code.rb
eddy-0.3.0 lib/definitions/elements/manual/116.postal_code.rb