add check for binding on multiple types

This commit is contained in:
Grahame Grieve 2022-01-29 09:16:05 +11:00
parent bd9d486846
commit dd65f5a975
2 changed files with 3 additions and 0 deletions

View File

@ -643,6 +643,7 @@ SD_ED_SHOULD_BIND_WITH_VS = The element {0} has a type that should have a bindin
SD_ED_BIND_UNKNOWN_VS = The valueSet reference {1} on element {0} could not be resolved
SD_ED_BIND_NOT_VS = The valueSet reference {1} on element {0} points to something that is not a value set ({2})
SD_ED_BIND_NO_BINDABLE = The element {0} has a binding, but no bindable types are present {1}
SD_ED_BIND_MULTIPLE_TYPES = The element {0} has a binding, and has multiple types ({1}). The binding will apply to all the types
DISCRIMINATOR_BAD_PATH = Error processing path expression for discriminator: {0} (src = ''{1}'')
SLICING_CANNOT_BE_EVALUATED = Slicing cannot be evaluated: {0}
TYPE_SPECIFIC_CHECKS_DT_CANONICAL_RESOLVE = Canonical URL ''{0}'' does not resolve

View File

@ -211,6 +211,8 @@ public class StructureDefinitionValidator extends BaseValidator {
private void validateBinding(List<ValidationMessage> errors, Element binding, NodeStack stack, Set<String> typeCodes, boolean snapshot, String path) {
rule(errors, IssueType.BUSINESSRULE, stack.getLiteralPath(), !snapshot || bindableType(typeCodes) != null, I18nConstants.SD_ED_BIND_NO_BINDABLE, path, typeCodes.toString());
hint(errors, IssueType.BUSINESSRULE, stack.getLiteralPath(), typeCodes.size() <= 1, I18nConstants.SD_ED_BIND_MULTIPLE_TYPES, path, typeCodes.toString());
if (binding.hasChild("valueSet")) {
Element valueSet = binding.getNamedChild("valueSet");
String ref = valueSet.hasPrimitiveValue() ? valueSet.primitiveValue() : valueSet.getNamedChildValue("reference");