First of all, when the method encounters a non-word character (\W), it stops parsing the string. This means that the string abc/def is rendered as abc. It would be less surprising to (at least have the option to) drop forbidden characters while retaining everything else, i.e. rendering the preceding as abc def.
Second, the character set that is used is incorrect. According to the NACHA spec (Appendix 1, section 1.2):
PART 1.2 Data Specifications for ACH Records
The following table shows the data specifications for ACH Records.
TYPE OF FIELD ALPHABETIC/ ALPHAMERIC
Valid Characters
0-9, A-Z, a-z, space, EBCDIC values greater than hexadecimal “3F”, ASCII values greater than hexadecimal “1F”
...
Certain fields require the use of UPPERCASE characters – see below.
Any ASCII characters above 1F are valid. Reading various bank's guides to implementing NACHA files, it sounds like they may support a restricted character set in practice. Are you aware of any reason not to support the full ASCII values 0x20 and above?
I can provide a PR implementing this if you'd accept this change.
The logic in
validate_alpha_numeric_field()
(https://github.com/travishathaway/python-ach/blob/master/ach/data_types.py#L57) produces incorrect and unexpected results.First of all, when the method encounters a non-word character (
\W
), it stops parsing the string. This means that the stringabc/def
is rendered asabc
. It would be less surprising to (at least have the option to) drop forbidden characters while retaining everything else, i.e. rendering the preceding asabc def
.Second, the character set that is used is incorrect. According to the NACHA spec (Appendix 1, section 1.2):
Any ASCII characters above 1F are valid. Reading various bank's guides to implementing NACHA files, it sounds like they may support a restricted character set in practice. Are you aware of any reason not to support the full ASCII values 0x20 and above?
I can provide a PR implementing this if you'd accept this change.