Skip to content

Commit c85e88a

Browse files
authored
Merge pull request #29 from jonsagara/feature/height
To support MI, a null or white space Height (`DAU`) value is not an error
2 parents 5b64ae3 + 96c471d commit c85e88a

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

src/IdParser.Core/IdParser.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<ImplicitUsings>enable</ImplicitUsings>
77

88
<!-- NuGet -->
9-
<Version>3.0.0-beta1</Version>
9+
<Version>3.0.0-beta2</Version>
1010
<AssemblyVersion>3.0.0</AssemblyVersion>
1111
<FileVersion>3.0.0</FileVersion>
1212
<Authors>Connor O'Shea, Jon Sagara</Authors>

src/IdParser.Core/Parsers/Id/HeightParser.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,19 @@ internal static class HeightParser
99
{
1010
ArgumentNullException.ThrowIfNull(elementId);
1111

12-
if (string.IsNullOrEmpty(rawValue) || rawValue.Length < 3)
12+
if (string.IsNullOrWhiteSpace(rawValue))
1313
{
14-
return FieldHelpers.UnparsedField<Height?>(elementId: elementId, rawValue: rawValue, $"Unable to parse Height from field '{SubfileElementIds.Height}': the field has no value, or has less than 3 characters: '{rawValue}'");
14+
// #28: For 2.0.0, I changed this to return an unparsed field error noting that the field had no value or
15+
// less than 3 characters. AAMVA says that DAU is required, and that when there is no data, it should be
16+
// encoded as NONE or unavl. MI does neither of those, and just leaves the field blank.
17+
// Split this into two separate checks: no value is not an error; return null.
18+
return FieldHelpers.ParsedField<Height?>(elementId: elementId, value: null, rawValue: rawValue);
19+
}
20+
21+
if (rawValue.Length < 3)
22+
{
23+
// #28: ... but we can't parse values that are less than 3 characters in length, so that's still an error.
24+
return FieldHelpers.UnparsedField<Height?>(elementId: elementId, rawValue: rawValue, $"Unable to parse Height from field '{SubfileElementIds.Height}': the field has less than 3 characters: '{rawValue}'");
1525
}
1626

1727
if (version == AAMVAVersion.AAMVA2000)

0 commit comments

Comments
 (0)