Handle document type definition with validation of publicId and systemId.
@param received
@param source
@param validationContext
@param namespaceContext
488898
private void doDocumentTypeDefinition(Node received, Node source,
            XmlMessageValidationContext validationContext,
            NamespaceContext namespaceContext, TestContext context) {

        Assert.isTrue(source instanceof DocumentType, "Missing document type definition in expected xml fragment");

        DocumentType receivedDTD = (DocumentType) received;
        DocumentType sourceDTD = (DocumentType) source;

        if (log.isDebugEnabled()) {
            log.debug("Validating document type definition: " +
                    receivedDTD.getPublicId() + " (" + receivedDTD.getSystemId() + ")");
        }

        if (!StringUtils.hasText(sourceDTD.getPublicId())) {
            Assert.isNull(receivedDTD.getPublicId(),
                    ValidationUtils.buildValueMismatchErrorMessage("Document type public id not equal",
                    sourceDTD.getPublicId(), receivedDTD.getPublicId()));
        } else if (sourceDTD.getPublicId().trim().equals(Citrus.IGNORE_PLACEHOLDER)) {
            if (log.isDebugEnabled()) {
                log.debug("Document type public id: '" + receivedDTD.getPublicId() +
                        "' is ignored by placeholder '" + Citrus.IGNORE_PLACEHOLDER + "'");
            }
        } else {
            Assert.isTrue(StringUtils.hasText(receivedDTD.getPublicId()) &&
                    receivedDTD.getPublicId().equals(sourceDTD.getPublicId()),
                    ValidationUtils.buildValueMismatchErrorMessage("Document type public id not equal",
                    sourceDTD.getPublicId(), receivedDTD.getPublicId()));
        }

        if (!StringUtils.hasText(sourceDTD.getSystemId())) {
            Assert.isNull(receivedDTD.getSystemId(),
                    ValidationUtils.buildValueMismatchErrorMessage("Document type system id not equal",
                    sourceDTD.getSystemId(), receivedDTD.getSystemId()));
        } else if (sourceDTD.getSystemId().trim().equals(Citrus.IGNORE_PLACEHOLDER)) {
            if (log.isDebugEnabled()) {
                log.debug("Document type system id: '" + receivedDTD.getSystemId() +
                        "' is ignored by placeholder '" + Citrus.IGNORE_PLACEHOLDER + "'");
            }
        } else {
            Assert.isTrue(StringUtils.hasText(receivedDTD.getSystemId()) &&
                    receivedDTD.getSystemId().equals(sourceDTD.getSystemId()),
                    ValidationUtils.buildValueMismatchErrorMessage("Document type system id not equal",
                    sourceDTD.getSystemId(), receivedDTD.getSystemId()));
        }

        validateXmlTree(received.getNextSibling(),
                source.getNextSibling(), validationContext, namespaceContext, context);
    }
193302
public final void validate(StringBuilder source) {

    int length = source.length();
    source.append('/');
    source.append(getSourceIdentifier());
    doValidate(source);
    // reset source for recursive invocation...
    source.setLength(length);
  }
1368294
private void validateTypeAnnotations(Node n, JSDocInfo info) {
    if (info != null && info.hasType()) {
      boolean valid = false;
      switch (n.getToken()) {
        // Function declarations are valid
        case FUNCTION:
          valid = NodeUtil.isFunctionDeclaration(n);
          break;
        // Object literal properties, catch declarations and variable
        // initializers are valid.
        case NAME:
          valid = isTypeAnnotationAllowedForName(n);
          break;
        case ARRAY_PATTERN:
        case OBJECT_PATTERN:
          // allow JSDoc like
          //   function f(/** !Object */ {x}) {}
          //   function f(/** !Array */ [x]) {}
          valid = n.getParent().isParamList();
          break;
        // Casts, exports, and Object literal properties are valid.
        case CAST:
        case EXPORT:
        case STRING_KEY:
        case GETTER_DEF:
        case SETTER_DEF:
          valid = true;
          break;
        // Declarations are valid iff they only contain simple names
        //   /** @type {number} */ var x = 3; // ok
        //   /** @type {number} */ var {x} = obj; // forbidden
        case VAR:
        case LET:
        case CONST:
          valid = !NodeUtil.isDestructuringDeclaration(n);
          break;
        // Property assignments are valid, if at the root of an expression.
        case ASSIGN: {
          Node lvalue = n.getFirstChild();
          valid = n.getParent().isExprResult()
              && (lvalue.isGetProp()
                  || lvalue.isGetElem()
                  || lvalue.matchesQualifiedName("exports"));
          break;
        }
        case GETPROP:
          valid = n.getParent().isExprResult() && n.isQualifiedName();
          break;
        case CALL:
          valid = info.isDefine();
          break;
        default:
          break;
      }

      if (!valid) {
        reportMisplaced(n, "type", "Type annotations are not allowed here. "
            + "Are you missing parentheses?");
      }
    }
  }
1046744
public static boolean isAttributeIgnored(Node receivedElement, Node receivedAttribute, Node sourceAttribute,
                                             Set<String> ignoreMessageElements, NamespaceContext namespaceContext) {
        if (isAttributeIgnored(receivedElement, receivedAttribute, ignoreMessageElements, namespaceContext)) {
            if (log.isDebugEnabled()) {
                log.debug("Attribute '" + receivedAttribute.getLocalName() + "' is on ignore list - skipped value validation");
            }

            return true;
        } else if ((StringUtils.hasText(sourceAttribute.getNodeValue()) &&
                sourceAttribute.getNodeValue().trim().equals(Citrus.IGNORE_PLACEHOLDER))) {
            if (log.isDebugEnabled()) {
                log.debug("Attribute: '" + receivedAttribute.getLocalName() + "' is ignored by placeholder '" +
                        Citrus.IGNORE_PLACEHOLDER + "'");
            }

            return true;
        }

        return false;
    }
275814
@Override
    public org.fcrepo.server.types.gen.Validation validate(String pid,
                                                           String asOfDateTime) {
        assertInitialized();
        try {
            MessageContext ctx = context.getMessageContext();
            return TypeUtility
                    .convertValidationToGenValidation(m_management.validate(ReadOnlyContext
                                                                                        .getSoapContext(ctx),
                                                                                pid,
                                                                                DateUtility
                                                                                        .parseDateOrNull(asOfDateTime)));
        } catch (Throwable th) {
            LOG.error("Error validating", th);
            throw CXFUtility.getFault(th);
        } finally {
            LOG.debug("end: validate");
        }
    }
1281466
public static boolean isElementIgnored(Node source, Node received, Set<String> ignoreExpressions, NamespaceContext namespaceContext) {
        if (isElementIgnored(received, ignoreExpressions, namespaceContext)) {
            if (log.isDebugEnabled()) {
                log.debug("Element: '" + received.getLocalName() + "' is on ignore list - skipped validation");
            }
            return true;
        } else if (source.getFirstChild() != null &&
                StringUtils.hasText(source.getFirstChild().getNodeValue()) &&
                source.getFirstChild().getNodeValue().trim().equals(Citrus.IGNORE_PLACEHOLDER)) {
            if (log.isDebugEnabled()) {
                log.debug("Element: '" + received.getLocalName() + "' is ignored by placeholder '" +
                        Citrus.IGNORE_PLACEHOLDER + "'");
            }
            return true;
        }
        return false;
    }
1153240
@Override
    public InputSource resolveEntity(String publicId, String systemId) throws SAXException {
        if (validating) {
            try {
                InputSource source = null;
                if (publicId != null) {
                    String path = doctypeMap.get(publicId.toUpperCase());
                    source = getInputSource(path);
                }
                if (source == null && systemId != null) {
                    String path = doctypeMap.get(systemId.toUpperCase());
                    source = getInputSource(path);
                }
                return source;
            } catch (Exception e) {
                throw new SAXException(e.toString());
            }
        } else {
            return new InputSource(new StringReader(""));
        }
    }
950068
public void validateXMLString(String xml, String dtdFile, String docType) throws SAXException, IOException, ParserConfigurationException {
    validateInternal(xml, dtdFile, docType);
  }
322966
@Override
    public ValidationResult validate(PMContext ctx) {
        final ValidationResult res = new ValidationResult();
        final Object object = ctx.getFieldValue();
        final String fieldId = ctx.getField().getId();

        if (object instanceof String) {
            String fieldvalue = (String) object;
            res.setSuccessful(true);
            Integer len = fieldvalue.length();
            Integer maxl = getInt("max-length");
            if (maxl != null) {
                if (len > maxl) {
                    res.setSuccessful(false);
                    res.getMessages().add(MessageFactory.error(
                            ctx.getEntity(), ctx.getField(),
                            get("max-length-msg", "pm_core.validator.toolong"),
                            fieldId, len.toString(), maxl.toString()));
                }
            }
            Integer minl = getInt("min-length");
            if (minl != null) {
                if (len < minl) {
                    res.setSuccessful(false);
                    res.getMessages().add(MessageFactory.error(
                            ctx.getEntity(), ctx.getField(),
                            get("min-length-msg", "pm_core.validator.tooshort"),
                            fieldId, len.toString(), minl.toString()));
                }
            }
        } else {
            res.setSuccessful(false);
            res.getMessages().add(MessageFactory.error(
                    ctx.getEntity(), ctx.getField(),
                    "pm_core.validator.fieldnotstring",
                    fieldId));
        }
        return res;
    }
1236932
public void validate(String origin) {
        List<String> problems = new ArrayList<>();
        if(source == null) {
            if(path == null) {
                problems.add("You must specify either path or source");
            } else if(method == null) {
                problems.add("You must specify method along with path: " + path);
            }
        } else {
            if(path != null) {
                problems.add("Conflicting source: " + source + " and path: " + path);
            }
            if(method != null) {
                problems.add("Conflicting source: " + source + " and method: " + method);
            }
        }
        if(method != null && !Util.METHODS.contains(method.toUpperCase())) {
            problems.add("Invalid HTTP method: " + method);
        }
        if(!problems.isEmpty()) {
            throw new RuntimeException("Bad paths element in " + origin + " [ " + String.join(" | ", problems) + " ]");
        }
    }
1030373
private void validateXMLSchema(InputStream objectAsStream, DOValidatorXMLSchema xsv)
            throws ObjectValidityException, GeneralException {

        try {
            xsv.validate(objectAsStream);
        } catch (ObjectValidityException e) {
            logger.error("VALIDATE: ERROR - failed XML Schema validation.", e);
            throw e;
        } catch (Exception e) {
            logger.error("VALIDATE: ERROR - failed XML Schema validation.", e);
            throw new ObjectValidityException("[DOValidatorImpl]: validateXMLSchema. "
                    + e.getMessage());
        }
        logger.debug("VALIDATE: SUCCESS - passed XML Schema validation.");
    }
386410
public void validate(final ValidationContext context) {
        if (!context.getUserEvent().equalsIgnoreCase("submit")) {
            return;
        }

        val messages = context.getMessageContext();
        ApplicationContextProvider.getCasConfigurationProperties().ifPresent(props -> {
            if (StringUtils.isBlank(source) && props.getAuthn().getPolicy().isSourceSelectionEnabled()) {
                messages.addMessage(new MessageBuilder()
                    .error()
                    .source("source")
                    .code("source.required")
                    .build());
            }
        });
    }
523045
protected void validateNamespace(final SqlValidatorNamespace namespace,
		RelDataType targetRowType) {
		namespace.validate(targetRowType);
		if (namespace.getNode() != null) {
			setValidatedNodeType(namespace.getNode(), namespace.getType());
		}
	}
1074035
public void validateEditDetails(GroupForm group, MessageContext context) {

        // ensure the group name is set
        if (StringUtils.isBlank(group.getName())) {
            context.addMessage(
                    new MessageBuilder().error().source("name").code("please.enter.name").build());
        }
    }
719105
public void submitContextString(final String evaluatorConfigurationString,
                                  final String contextConfigurationString) {
    if (evaluatorConfigurationString.isEmpty()) {
      throw new RuntimeException("empty evaluatorConfigurationString provided.");
    }
    if (contextConfigurationString.isEmpty()) {
      throw new RuntimeException("empty contextConfigurationString provided.");
    }

    //When submit over the bridge, we would keep the contextConfigurationString as serialized strings.
    //public void submitContext(final String contextConfiguration)
    // is not exposed in the interface. Therefore cast is necessary.
    ((AllocatedEvaluatorImpl)jallocatedEvaluator).submitContext(
        evaluatorConfigurationString, contextConfigurationString);
  }
1370342
protected void validateAttachmentContentData(String receivedContent, String controlContent, String controlContentId) {
        if (ignoreAllWhitespaces) {
            controlContent = StringUtils.trimAllWhitespace(controlContent);
            receivedContent = StringUtils.trimAllWhitespace(receivedContent);
        }

        Assert.isTrue(receivedContent.equals(controlContent),
                "Values not equal for attachment content '"
                        + controlContentId + "', expected '"
                        + controlContent.trim() + "' but was '"
                        + receivedContent.trim() + "'");
    }
319003
protected void validateAttachmentContentId(SoapAttachment receivedAttachment, SoapAttachment controlAttachment) {
        //in case contentId was not set in test case, skip validation 
        if (!StringUtils.hasText(controlAttachment.getContentId())) { return; }
        
        if (receivedAttachment.getContentId() != null) {
            Assert.isTrue(controlAttachment.getContentId() != null, 
                    buildValidationErrorMessage("Values not equal for attachment contentId", 
                            null, receivedAttachment.getContentId()));

            Assert.isTrue(receivedAttachment.getContentId().equals(controlAttachment.getContentId()),
                    buildValidationErrorMessage("Values not equal for attachment contentId", 
                            controlAttachment.getContentId(), receivedAttachment.getContentId()));
        } else {
            Assert.isTrue(controlAttachment.getContentId() == null || controlAttachment.getContentId().length() == 0, 
                    buildValidationErrorMessage("Values not equal for attachment contentId", 
                            controlAttachment.getContentId(), null));
        }
        
        if (log.isDebugEnabled()) {
            log.debug("Validating attachment contentId: " + receivedAttachment.getContentId() + 
                    "='" + controlAttachment.getContentId() + "': OK.");
        }
    }