fix validation tests

This commit is contained in:
Grahame Grieve 2019-07-30 16:50:54 +10:00
parent fe219985b4
commit f5b5737398
5 changed files with 11 additions and 14 deletions

View File

@ -222,4 +222,6 @@
</test>
<test gen="true" id="samply1">
</test>
<test gen="true" id="au1" include="au1a">
</test>
</snapshot-generation-tests>

View File

@ -165,6 +165,12 @@ public class Utilities {
return DecimalStatus.BLANK;
}
// check for leading zeros
if (value.startsWith("0") && !"0".equals(value) && !value.startsWith("0."))
return DecimalStatus.SYNTAX;
if (value.startsWith("-0") && !"-0".equals(value) && !value.startsWith("-0."))
return DecimalStatus.SYNTAX;
boolean havePeriod = false;
boolean haveExponent = false;
boolean haveMinus = false;

View File

@ -799,7 +799,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
}
private boolean check(String v1, String v2) {
return v1 == null ? Utilities.noString(v2) : v1.equals(v2);
return v1 == null ? Utilities.noString(v1) : v1.equals(v2);
}
private void checkAddress(List<ValidationMessage> errors, String path, Element focus, Address fixed) {
@ -1641,17 +1641,6 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
DecimalStatus ds = Utilities.checkDecimal(e.primitiveValue(), true);
if (rule(errors, IssueType.INVALID, e.line(), e.col(), path, ds == DecimalStatus.OK || ds == DecimalStatus.RANGE, "The value '" + e.primitiveValue() + "' is not a valid decimal"))
warning(errors, IssueType.VALUE, e.line(), e.col(), path, ds != DecimalStatus.RANGE, "The value '" + e.primitiveValue() + "' is outside the range of commonly/reasonably supported decimals");
if (e.primitiveValue().contains(".")) {
String head = e.primitiveValue().substring(0, e.primitiveValue().indexOf("."));
if (head.startsWith("-"))
head = head.substring(1);
int i = 0;
while (head.startsWith("0")) {
i++;
head = head.substring(1);
}
rule(errors, IssueType.INVALID, e.line(), e.col(), path, i <= 1, "The value '" + e.primitiveValue() + "' is not a valid decimal (leading 0s)");
}
}
}
if (type.equals("instant")) {

View File

@ -196,7 +196,8 @@
"errorCount": 0
},
"primitive-bad.xml": {
"errorCount": 47
"errorCount": 47,
"warningCount": 2
},
"primitive-bad-empty.xml": {
"errorCount": 3

View File

@ -71,7 +71,6 @@
<display
value="Cholesterol [Moles/volume] in Serum or Plasma" />
</coding>
<text value="Cholesterol" />
</code>
<subject>
<reference value="Patient/pat2" />