Validates objects using Hibernate Validator.
@param content an object to be validated
@return a list of error messages or empty if object is valid
777643
public static String[] validateObject(ParaObject content) {
		if (content == null) {
			return new String[]{"Object cannot be null."};
		}
		LinkedList<String> list = new LinkedList<>();
		try {
			for (ConstraintViolation<ParaObject> constraintViolation : getValidator().validate(content)) {
				String prop = "'".concat(constraintViolation.getPropertyPath().toString()).concat("'");
				list.add(prop.concat(" ").concat(constraintViolation.getMessage()));
			}
		} catch (Exception e) {
			logger.error(null, e);
		}
		return list.toArray(new String[]{});
	}
991119
@Override
    public String validate(DTDValidatorBase v, char[] cbuf, int start, int end, boolean normalize)
        throws XMLValidationException
    {
        // Nothing to do for pure CDATA attributes...
        return null;
    }
673771
@Override
	public boolean validate(final Problems problems, final String compName, final String model) {
		return this.other.validate(problems, compName, model == null ? null : model.trim());
	}
296721
private static void validateEntities(org.w3c.dom.Element document, JsonNode entityJson) throws InvalidInputException,
      ProcessingException {
    XPathFactory xPathfactory = XPathFactory.newInstance();
    XPath xpath = xPathfactory.newXPath();

    NodeList nodes;
    try {
      XPathExpression expr = xpath.compile("//@data-entity-id");
      nodes = (NodeList) expr.evaluate(document, XPathConstants.NODESET);
    } catch (XPathExpressionException e) {
      throw new ProcessingException("Internal error processing document tree: " + e.getMessage());
    }

    for (int i = 0; i < nodes.getLength(); i++) {
      Node node = nodes.item(i);
      String entityId = ((org.w3c.dom.Attr) node).getValue();

      JsonNode entityNode = entityJson.findPath(entityId);
      if (entityNode.isMissingNode()) {
        throw new InvalidInputException("Error processing EntityJSON: "
            + "no entity data provided for \"data-entity-id\"=\"" + entityId + "\"");
      } else if (!entityNode.isObject()) {
        throw new InvalidInputException("Error processing EntityJSON: "
            + "the node \"" + entityId + "\" has to be an object");
      }
    }
  }
1273543
@Override
   public List<String> getBeanValidationGroups()
   {
      return beanValidationGroups == null ? null : Collections.unmodifiableList(beanValidationGroups);
   }
458259
protected List<ValidationContext> parseValidationContexts(Element messageElement, BeanDefinitionBuilder builder) {
        List<ValidationContext> validationContexts = new ArrayList<>();
        if (messageElement != null) {
            String messageType = messageElement.getAttribute("type");
            if (!StringUtils.hasText(messageType)) {
                messageType = Citrus.DEFAULT_MESSAGE_TYPE;
            } else {
                builder.addPropertyValue("messageType", messageType);
            }

            HeaderValidationContext headerValidationContext = new HeaderValidationContext();
            validationContexts.add(headerValidationContext);

            String headerValidator = messageElement.getAttribute("header-validator");
            if (StringUtils.hasText(headerValidator)) {
                headerValidationContext.addHeaderValidator(headerValidator);
            }

            String headerValidatorExpression = messageElement.getAttribute("header-validators");
            if (StringUtils.hasText(headerValidatorExpression)) {
                Stream.of(headerValidatorExpression.split(","))
                        .map(String::trim)
                        .forEach(headerValidationContext::addHeaderValidator);
            }

            XmlMessageValidationContext xmlMessageValidationContext = getXmlMessageValidationContext(messageElement);
            validationContexts.add(xmlMessageValidationContext);

            XpathMessageValidationContext xPathMessageValidationContext = getXPathMessageValidationContext(messageElement, xmlMessageValidationContext);
            if (!xPathMessageValidationContext.getXpathExpressions().isEmpty()) {
                validationContexts.add(xPathMessageValidationContext);
            }

            JsonMessageValidationContext jsonMessageValidationContext = getJsonMessageValidationContext(messageElement);
            validationContexts.add(jsonMessageValidationContext);

            JsonPathMessageValidationContext jsonPathMessageValidationContext = getJsonPathMessageValidationContext(messageElement);
            if (!jsonPathMessageValidationContext.getJsonPathExpressions().isEmpty()) {
                validationContexts.add(jsonPathMessageValidationContext);
            }

            ScriptValidationContext scriptValidationContext = getScriptValidationContext(messageElement, messageType);
            if (scriptValidationContext != null) {
                validationContexts.add(scriptValidationContext);
            }

            ManagedList<RuntimeBeanReference> validators = new ManagedList<>();
            String messageValidator = messageElement.getAttribute("validator");
            if (StringUtils.hasText(messageValidator)) {
                validators.add(new RuntimeBeanReference(messageValidator));
            }

            String messageValidatorExpression = messageElement.getAttribute("validators");
            if (StringUtils.hasText(messageValidatorExpression)) {
                Stream.of(messageValidatorExpression.split(","))
                        .map(String::trim)
                        .map(RuntimeBeanReference::new)
                        .forEach(validators::add);
            }

            if (!validators.isEmpty()) {
                builder.addPropertyValue("validators", validators);
            }

            String dataDictionary = messageElement.getAttribute("data-dictionary");
            if (StringUtils.hasText(dataDictionary)) {
                builder.addPropertyReference("dataDictionary", dataDictionary);
            }
        } else {
            validationContexts.add(new HeaderValidationContext());
        }

        return validationContexts;
    }
1078654
public List<Failure> validate(List<Validate> objects)
   {
      if (objects == null || objects.isEmpty())
         return null;

      return execRulesOnValidates(objects);
   }
158968
@Override
	public boolean validate(final Problems problems, final String compName, final String model) {
		if (model.length() % 2 != 0) {
			problems.add(ValidationBundle.getMessage(ValidHexadecimalNumberValidator.class, "ODD_LENGTH_HEX", compName)); // NOI18N
			return false;
		}
		for (final char c : model.toCharArray()) {
			final boolean good = c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f' || c >= '0' && c <= '9';
			if (!good) {
				problems.add(ValidationBundle.getMessage(ValidHexadecimalNumberValidator.class, "INVALID_HEX", // NOI18N
						new String(new char[] { c }), compName));
				return false;
			}
		}
		return true;
	}
1076015
public List<String> validate(Entity entity) throws APIException, ConnectionException, OidException {
    	Asset asset = v1Instance.getAsset(entity.getInstanceKey()) != null ? v1Instance.getAsset(entity.getInstanceKey()) : v1Instance.getAsset(entity.getID());
        return validate(asset);
    }
801399
@Override
    public String validate(DTDValidatorBase v, char[] cbuf, int start, int end, boolean normalize)
        throws XMLStreamException
    {
        while (start < end && WstxInputData.isSpaceChar(cbuf[start])) {
            ++start;
        }

        // Empty value?
        if (start >= end) {
            return reportValidationProblem(v, "Empty ENTITY value");
        }
        --end; // so that it now points to the last char
        while (end > start  && WstxInputData.isSpaceChar(cbuf[end])) {
            --end;
        }

        // Ok, need to check char validity, and also calc hash code:
        char c = cbuf[start];
        if (!WstxInputData.isNameStartChar(c, mCfgNsAware, mCfgXml11) && c != ':') {
            return reportInvalidChar(v, c, "not valid as the first ID character");
        }
        for (int i = start+1; i <= end; ++i) {
            c = cbuf[i];
            if (!WstxInputData.isNameChar(c, mCfgNsAware, mCfgXml11)) {
                return reportInvalidChar(v, c, "not valid as an ID character");
            }
        }

        EntityDecl ent = findEntityDecl(v, cbuf, start, (end - start + 1));
        // only returns if it succeeded...

        return normalize ? ent.getName() : null;
    }
888490
@Override
  public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
    final String valueAsString;
    if (ignoreWhitspaces) {
      valueAsString =
          Objects.toString(pvalue, StringUtils.EMPTY).replaceAll("\\s+", StringUtils.EMPTY);
    } else {
      valueAsString = Objects.toString(pvalue, null);
    }
    if (StringUtils.isEmpty(valueAsString)) {
      // empty field is ok
      return true;
    }
    if (valueAsString.length() != BicValidator.BIC_LENGTH_MIN
        && valueAsString.length() != BicValidator.BIC_LENGTH_MAX) {
      // to short or to long, but it's handled by size validator!
      return true;
    }
    if (!valueAsString.matches(BicValidator.BIC_REGEX)) {
      // format is wrong!
      return false;
    }
    // final BicMapConstants BIC_MAP = CreateClass.create(BicMapConstants.class);
    return BIC_MAP.bics().containsKey(valueAsString) || BIC_MAP.bics()
        .containsKey(StringUtils.substring(valueAsString, 0, BicValidator.BIC_LENGTH_MIN));
  }
336543
public void validate(TestClass target, List<Throwable> errors) {
        List<? extends FrameworkMember<?>> members = methods ? target.getAnnotatedMethods(annotation)
                : target.getAnnotatedFields(annotation);

        for (FrameworkMember<?> each : members) {
            validateMember(each, errors);
        }
    }
827527
public static String cleanInvalid(String xmlContent) {
		if (xmlContent == null) {
			return null;
		}
		return xmlContent.replaceAll(INVALID_REGEX, "");
	}
843897
public Response andContent(Map<String, Object> content) {
        Objects.requireNonNull(content, Required.CONTENT.toString());
        this.content.putAll(content);

        return this;
    }
113803
public void validate(Object o)
    {
        if (o != null && o instanceof String)
        {
            int l = ((String)o).length();
            if (m_minLength != -1 && l < m_minLength)
            {
                String message = m_propertyMetadata.getMessageSourceAccessor().getMessage(m_message, new Object[]{ m_propertyMetadata.getLabelName(), m_minLength,m_maxLength,String.valueOf(o) });
                throw new ValidationException(message);                
            }
            if (m_maxLength != -1 && l > m_maxLength)
            {
                String message = m_propertyMetadata.getMessageSourceAccessor().getMessage(m_message, new Object[]{ m_propertyMetadata.getLabelName(),m_minLength,m_maxLength, String.valueOf(o) });
                throw new ValidationException(message);                
            }
        }
    }
599805
@Override
  public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
    if (pvalue == null) {
      return true;
    }
    try {
      String countryCode =
          BeanPropertyReaderUtil.getNullSaveStringProperty(pvalue, fieldCountryCode);
      final String postalCode =
          BeanPropertyReaderUtil.getNullSaveStringProperty(pvalue, fieldPostalCode);
      if (StringUtils.isEmpty(postalCode)) {
        return true;
      }

      if (allowLowerCaseCountryCode) {
        countryCode = StringUtils.upperCase(countryCode);
      }

      final String regExCheck = POSTAL_CODE_MAP.postalCodes().get(countryCode);
      if (regExCheck == null) {
        return true;
      }
      if (postalCode.matches(regExCheck)) {
        return true;
      }
      switchContext(pcontext);
      return false;
    } catch (final Exception ignore) {
      switchContext(pcontext);
      return false;
    }
  }
441635
protected <S extends Serializable> void validateDomainObject(S domainObject, Set<ATError> errors) {
		Set<ConstraintViolation<S>> constraintViolations = validator.validate( domainObject );
		if (CollectionUtils.isEmpty(constraintViolations)) {
			return;
		}
		for ( ConstraintViolation<S> violation : constraintViolations ) {
			String type = violation.getConstraintDescriptor().getAnnotation().annotationType().getSimpleName();
			String attrPath = violation.getPropertyPath().toString();
			String msgKey = attrPath + "." + type;
			if (null != violation.getMessage() && violation.getMessage().startsWith(MSG_KEY_PREFIX)) {
				msgKey = violation.getMessage();
			}
			errors.add(new ATError((attrPath + "." + type), getMessage(msgKey, new Object[]{attrPath}, violation.getMessage()), attrPath));
		}
	}