fix bugs in v1.4 validation
This commit is contained in:
parent
5e27541288
commit
91cf756386
|
@ -414,6 +414,18 @@ public class NpmPackage {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* use the name from listResources()
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public InputStream loadResource(String file) throws IOException {
|
||||||
|
NpmPackageFolder folder = folders.get("package");
|
||||||
|
return new ByteArrayInputStream(folder.fetchFile(file));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get a stream that contains the contents of one of the files in a folder
|
* get a stream that contains the contents of one of the files in a folder
|
||||||
*
|
*
|
||||||
|
|
|
@ -1908,7 +1908,9 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
if (type.equals("uri") || type.equals("oid") || type.equals("uuid") || type.equals("url") || type.equals("canonical")) {
|
if (type.equals("uri") || type.equals("oid") || type.equals("uuid") || type.equals("url") || type.equals("canonical")) {
|
||||||
rule(errors, IssueType.INVALID, e.line(), e.col(), path, !e.primitiveValue().startsWith("oid:"), "URI values cannot start with oid:");
|
rule(errors, IssueType.INVALID, e.line(), e.col(), path, !e.primitiveValue().startsWith("oid:"), "URI values cannot start with oid:");
|
||||||
rule(errors, IssueType.INVALID, e.line(), e.col(), path, !e.primitiveValue().startsWith("uuid:"), "URI values cannot start with uuid:");
|
rule(errors, IssueType.INVALID, e.line(), e.col(), path, !e.primitiveValue().startsWith("uuid:"), "URI values cannot start with uuid:");
|
||||||
rule(errors, IssueType.INVALID, e.line(), e.col(), path, e.primitiveValue().equals(e.primitiveValue().trim().replace(" ", "")), "URI values cannot have whitespace");
|
rule(errors, IssueType.INVALID, e.line(), e.col(), path, e.primitiveValue().equals(e.primitiveValue().trim().replace(" ", ""))
|
||||||
|
// work around an old invalid example in a core package
|
||||||
|
&& !"http://www.acme.com/identifiers/patient or urn:ietf:rfc:3986 if the Identifier.value itself is a full uri".equals(e.primitiveValue()), "URI values cannot have whitespace('"+e.primitiveValue()+"')");
|
||||||
rule(errors, IssueType.INVALID, e.line(), e.col(), path, !context.hasMaxLength() || context.getMaxLength()==0 || e.primitiveValue().length() <= context.getMaxLength(), "value is longer than permitted maximum length of " + context.getMaxLength());
|
rule(errors, IssueType.INVALID, e.line(), e.col(), path, !context.hasMaxLength() || context.getMaxLength()==0 || e.primitiveValue().length() <= context.getMaxLength(), "value is longer than permitted maximum length of " + context.getMaxLength());
|
||||||
|
|
||||||
|
|
||||||
|
@ -1932,8 +1934,11 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type.equals("id")) {
|
if (type.equals("id")) {
|
||||||
|
// work around an old issue with ElementDefinition.id
|
||||||
|
if (!context.getPath().equals("ElementDefinition.id") && !VersionUtilities.versionsCompatible("1.4", this.context.getVersion())) {
|
||||||
rule(errors, IssueType.INVALID, e.line(), e.col(), path, FormatUtilities.isValidId(e.primitiveValue()), "id value '"+e.primitiveValue()+"' is not valid");
|
rule(errors, IssueType.INVALID, e.line(), e.col(), path, FormatUtilities.isValidId(e.primitiveValue()), "id value '"+e.primitiveValue()+"' is not valid");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (type.equalsIgnoreCase("string") && e.hasPrimitiveValue()) {
|
if (type.equalsIgnoreCase("string") && e.hasPrimitiveValue()) {
|
||||||
if (rule(errors, IssueType.INVALID, e.line(), e.col(), path, e.primitiveValue() == null || e.primitiveValue().length() > 0, "@value cannot be empty")) {
|
if (rule(errors, IssueType.INVALID, e.line(), e.col(), path, e.primitiveValue() == null || e.primitiveValue().length() > 0, "@value cannot be empty")) {
|
||||||
warning(errors, IssueType.INVALID, e.line(), e.col(), path, e.primitiveValue() == null || e.primitiveValue().trim().equals(e.primitiveValue()), "value should not start or finish with whitespace");
|
warning(errors, IssueType.INVALID, e.line(), e.col(), path, e.primitiveValue() == null || e.primitiveValue().trim().equals(e.primitiveValue()), "value should not start or finish with whitespace");
|
||||||
|
@ -2194,6 +2199,9 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
warning(errors, IssueType.STRUCTURE, element.line(), element.col(), path, !Utilities.noString(element.getNamedChildValue("display")), "A Reference without an actual reference or identifier should have a display");
|
warning(errors, IssueType.STRUCTURE, element.line(), element.col(), path, !Utilities.noString(element.getNamedChildValue("display")), "A Reference without an actual reference or identifier should have a display");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
} else if (Utilities.existsInList(ref, "http://tools.ietf.org/html/bcp47")) {
|
||||||
|
// special known URLs that can't be validated but are known to be valid
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Element we = localResolve(ref, stack, errors, path);
|
Element we = localResolve(ref, stack, errors, path);
|
||||||
|
@ -3596,7 +3604,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
else if (itemType.equals("string")) checkOption(errors, answer, ns, qsrc, qItem, "string", true);
|
else if (itemType.equals("string")) checkOption(errors, answer, ns, qsrc, qItem, "string", true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case QUESTION:
|
// case QUESTION:
|
||||||
case NULL:
|
case NULL:
|
||||||
// no validation
|
// no validation
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue