From df26867adb54e31e503b51ea46696b674fde17cd Mon Sep 17 00:00:00 2001 From: Jon Sagara Date: Thu, 21 Mar 2024 08:23:15 -0700 Subject: [PATCH] #28: A null or white space DAU (height) element value should not be treated as an error. A value less than 3 characters in length should still be treated as an error. --- src/IdParser.Core/Parsers/Id/HeightParser.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/IdParser.Core/Parsers/Id/HeightParser.cs b/src/IdParser.Core/Parsers/Id/HeightParser.cs index 8f8e70d..17959d1 100644 --- a/src/IdParser.Core/Parsers/Id/HeightParser.cs +++ b/src/IdParser.Core/Parsers/Id/HeightParser.cs @@ -9,9 +9,19 @@ internal static class HeightParser { ArgumentNullException.ThrowIfNull(elementId); - if (string.IsNullOrEmpty(rawValue) || rawValue.Length < 3) + if (string.IsNullOrWhiteSpace(rawValue)) { - return FieldHelpers.UnparsedField(elementId: elementId, rawValue: rawValue, $"Unable to parse Height from field '{SubfileElementIds.Height}': the field has no value, or has less than 3 characters: '{rawValue}'"); + // #28: For 2.0.0, I changed this to return an unparsed field error noting that the field had no value or + // less than 3 characters. AAMVA says that DAU is required, and that when there is no data, it should be + // encoded as NONE or unavl. MI does neither of those, and just leaves the field blank. + // Split this into two separate checks: no value is not an error; return null. + return FieldHelpers.ParsedField(elementId: elementId, value: null, rawValue: rawValue); + } + + if (rawValue.Length < 3) + { + // #28: ... but we can't parse values that are less than 3 characters in length, so that's still an error. + return FieldHelpers.UnparsedField(elementId: elementId, rawValue: rawValue, $"Unable to parse Height from field '{SubfileElementIds.Height}': the field has less than 3 characters: '{rawValue}'"); } if (version == AAMVAVersion.AAMVA2000)