revise validation of resource and element id

This commit is contained in:
Grahame Grieve 2021-08-27 09:59:17 +10:00
parent b3b43c17d1
commit 3cb384a297
2 changed files with 9 additions and 6 deletions

View File

@ -118,7 +118,7 @@ Reference_REF_NoType = Unable to determine type of target resource
Reference_REF_NotFound_Bundle = Bundled or contained reference not found within the bundle/resource {0} Reference_REF_NotFound_Bundle = Bundled or contained reference not found within the bundle/resource {0}
Reference_REF_ResourceType = Matching reference for reference {0} has resourceType {1} Reference_REF_ResourceType = Matching reference for reference {0} has resourceType {1}
Reference_REF_WrongTarget = The type ''{0}'' is not a valid Target for this element (must be one of {1}) Reference_REF_WrongTarget = The type ''{0}'' is not a valid Target for this element (must be one of {1})
Resource_RES_ID_Malformed = Resource id not formatted correctly Resource_RES_ID_Malformed = Invalid Resource id
Resource_RES_ID_Missing = Resource requires an id, but none is present Resource_RES_ID_Missing = Resource requires an id, but none is present
Resource_RES_ID_Prohibited = Resource has an id, but none is allowed Resource_RES_ID_Prohibited = Resource has an id, but none is allowed
Terminology_PassThrough_TX_Message = {0} for ''{1}#{2}'' Terminology_PassThrough_TX_Message = {0} for ''{1}#{2}''

View File

@ -2056,7 +2056,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
} }
} }
} }
if (type.equals(ID)) { if (type.equals(ID) && !"Resource.id".equals(context.getBase().getPath())) {
// work around an old issue with ElementDefinition.id // work around an old issue with ElementDefinition.id
if (!context.getPath().equals("ElementDefinition.id")) { if (!context.getPath().equals("ElementDefinition.id")) {
rule(errors, IssueType.INVALID, e.line(), e.col(), path, FormatUtilities.isValidId(e.primitiveValue()), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_ID_VALID, e.primitiveValue()); rule(errors, IssueType.INVALID, e.line(), e.col(), path, FormatUtilities.isValidId(e.primitiveValue()), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_ID_VALID, e.primitiveValue());
@ -5173,10 +5173,13 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), false, I18nConstants.RESOURCE_RES_ID_MISSING); rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), false, I18nConstants.RESOURCE_RES_ID_MISSING);
} else if (idstatus == IdStatus.PROHIBITED && (element.getNamedChild(ID) != null)) { } else if (idstatus == IdStatus.PROHIBITED && (element.getNamedChild(ID) != null)) {
rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), false, I18nConstants.RESOURCE_RES_ID_PROHIBITED); rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), false, I18nConstants.RESOURCE_RES_ID_PROHIBITED);
} else if ((idstatus == IdStatus.OPTIONAL || idstatus == IdStatus.REQUIRED) }
&& (element.getNamedChild(ID) != null) if (element.getNamedChild(ID) != null) {
&& (!idFormattedCorrectly(element.getNamedChild(ID).getValue()))) { Element eid = element.getNamedChild(ID);
rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), false, I18nConstants.RESOURCE_RES_ID_MALFORMED); if (eid.getProperty() != null && eid.getProperty().getDefinition() != null && eid.getProperty().getDefinition().getBase().getPath().equals("Resource.id")) {
NodeStack ns = stack.push(eid, -1, eid.getProperty().getDefinition(), null);
rule(errors, IssueType.INVALID, eid.line(), eid.col(), ns.getLiteralPath(), idFormattedCorrectly(eid.getValue()), I18nConstants.RESOURCE_RES_ID_MALFORMED);
}
} }
start(hostContext, errors, element, element, defn, stack); // root is both definition and type start(hostContext, errors, element, element, defn, stack); // root is both definition and type
} }