Rynaro / estratto

parsing fixed width files content made easy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement allow_empty field for formats

Rynaro opened this issue · comments

Third-party files sometimes has lack of data integrity. It's not uncommon, you need to parse a date (like birthdate), and third-party file does not contain this information in the specified range.
Today, estratto raises error trying to parse the date format, 'cause ' ' isnt valid date to parse.


Proposal change:

In formats node, we'll insert a new property called allow_empty receiving a boolean value. When this value was true, estratto will return nil value to avoid any problems, and keeping data integrity. (Using premise, if we don't get data from range, a nil data can describe the actual state)
If value is false or allow_empty omitted, estratto will raise errors as default behaviour.


Technical usage proposal:

        - name: birthdate
          range: 137..144
          type: DateTime
          formats:
            allow_empty: true
            format: '%Y%m%d'

allow_empty is a nice name!