Validate
@param vo The validate object
@param rb The resource bundle
@return The list of failures found; <code>null</code> if none
498045
@SuppressWarnings("unchecked")
   public List<Failure> validate(Validate vo, ResourceBundle rb)
   {
      if (vo != null && Key.CONNECTION_FACTORY == vo.getKey())
      {
         if (vo.getClazz() == null)
         {
            ValidateClass vc = (ValidateClass)vo;

            List<Failure> failures = new ArrayList<Failure>(1);
            Failure failure = null;

            String code = null;
            if (vc.getClassName() != null)
            {
               code = vc.getClassName().equals("") ? "<empty>" : vc.getClassName() +
                  " (" + vc.getClassLoader().toString() + ")";
            }

            if (code != null)
            {
               failure = new Failure(Severity.ERROR,
                                     SECTION,
                                     rb.getString("cf.CFNull"),
                                     code);
            }
            else
            {
               failure = new Failure(Severity.ERROR,
                                     SECTION,
                                     rb.getString("cf.CFNull"));
            }

            failures.add(failure);

            return failures;
         }
      }

      return null;
   }
594057
protected static void validateBool(String opName, SDVariable v) {
        if (v == null)
            return;
        if (v.dataType() != DataType.BOOL)
            throw new IllegalStateException("Cannot apply operation \"" + opName + "\" to variable \"" + v.getVarName() + "\" with non-boolean point data type " + v.dataType());
    }
213948
public static boolean validateResource(String uriString) {
        if(uriString == null) {
            return false;
        }

        try {
            return validateResource(createUri(uriString));
        } catch(DataSourceException e) {
            Log.d(TAG, "URI is not valid", e);
            return false;
        }
    }
891526
public static boolean validateResource(URI uri) {
        return uri != null && uri.getPort() != -1 && uri.getHost() != null;
    }
208998
def check_for_status_code_failure(azure_response)
      fail MsRest::ValidationError, 'Azure response cannot be nil' if azure_response.nil?
      fail MsRest::ValidationError, 'Azure response cannot have empty response object' if azure_response.response.nil?
      fail MsRest::ValidationError, 'Azure response cannot have empty request object' if azure_response.request.nil?

      status_code = azure_response.response.status
      http_method = azure_response.request.method

      fail AzureOperationError, "Unexpected polling status code from long running operation #{status_code}" unless status_code === 200 || status_code === 202 ||
          (status_code === 201 && http_method === :put) ||
          (status_code === 204 && (http_method === :delete || http_method === :post))
    end
714397
private static List<Validate> createAdminObject(Connector cmd,
         List<Failure> failures, ResourceBundle rb, ClassLoader cl)
   {
      List<Validate> result = new ArrayList<Validate>();

      if (cmd.getVersion() != Version.V_10 &&
          cmd.getResourceadapter() != null &&
          cmd.getResourceadapter().getAdminObjects() != null)
      {
         List<AdminObject> aoMetas = cmd.getResourceadapter().getAdminObjects();
         if (!aoMetas.isEmpty())
         {
            for (AdminObject aoMeta : aoMetas)
            {
               if (aoMeta.getAdminobjectClass() != null
                     && !aoMeta.getAdminobjectClass().equals(XsdString.NULL_XSDSTRING))
               {

                  try
                  {
                     Class<?> clazz = Class.forName(aoMeta.getAdminobjectClass().getValue(), true, cl);
                     List<ConfigProperty> configProperties = aoMeta.getConfigProperties();

                     ValidateClass vc = new ValidateClass(Key.ADMIN_OBJECT, clazz, configProperties);
                     result.add(vc);
                  }
                  catch (ClassNotFoundException e)
                  {
                     Failure failure = new Failure(Severity.ERROR,
                                                   rb.getString("uncategorized"),
                                                   rb.getString("ao.cnfe"),
                                                   e.getMessage());
                     failures.add(failure);
                  }
               }
            }
         }
      }
      return result;
   }
293102
protected void validate(String operationType) throws Exception
	{
		super.validate(operationType);

		MPSString id_validator = new MPSString();
		id_validator.validate(operationType, id, "\"id\"");
		
		MPSBoolean secure_access_only_validator = new MPSBoolean();
		secure_access_only_validator.validate(operationType, secure_access_only, "\"secure_access_only\"");
		
		MPSString svm_ns_comm_validator = new MPSString();
		svm_ns_comm_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 10);
		svm_ns_comm_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		svm_ns_comm_validator.validate(operationType, svm_ns_comm, "\"svm_ns_comm\"");
		
		MPSString ns_br_interface_validator = new MPSString();
		ns_br_interface_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 10);
		ns_br_interface_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		ns_br_interface_validator.validate(operationType, ns_br_interface, "\"ns_br_interface\"");
		
		MPSBoolean vm_auto_poweron_validator = new MPSBoolean();
		vm_auto_poweron_validator.validate(operationType, vm_auto_poweron, "\"vm_auto_poweron\"");
		
		MPSString ns_br_interface_2_validator = new MPSString();
		ns_br_interface_2_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 10);
		ns_br_interface_2_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		ns_br_interface_2_validator.validate(operationType, ns_br_interface_2, "\"ns_br_interface_2\"");
		
		MPSInt init_status_validator = new MPSInt();
		init_status_validator.validate(operationType, init_status, "\"init_status\"");
		
	}
1333870
protected void validate(String operationType) throws Exception
	{
		super.validate(operationType);

		MPSString id_validator = new MPSString();
		id_validator.setConstraintIsReq(MPSConstants.DELETE_CONSTRAINT, true);
		id_validator.setConstraintIsReq(MPSConstants.MODIFY_CONSTRAINT, true);
		id_validator.validate(operationType, id, "\"id\"");
		
		MPSString category_validator = new MPSString();
		category_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 1024);
		category_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		category_validator.validate(operationType, category, "\"category\"");
		
		MPSString entity_validator = new MPSString();
		entity_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 1024);
		entity_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		entity_validator.validate(operationType, entity, "\"entity\"");
		
		MPSString severity_validator = new MPSString();
		severity_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 32);
		severity_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		severity_validator.validate(operationType, severity, "\"severity\"");
		
		MPSString source_validator = new MPSString();
		source_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 128);
		source_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		source_validator.validate(operationType, source, "\"source\"");
		
		MPSString failureobj_validator = new MPSString();
		failureobj_validator.setConstraintCharSetRegEx(MPSConstants.GENERIC_CONSTRAINT,"[ a-zA-Z0-9_#.:@=-]+");
		failureobj_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 128);
		failureobj_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		failureobj_validator.validate(operationType, failureobj, "\"failureobj\"");
		
		MPSInt source_event_id_validator = new MPSInt();
		source_event_id_validator.validate(operationType, source_event_id, "\"source_event_id\"");
		
		MPSInt timestamp_validator = new MPSInt();
		timestamp_validator.validate(operationType, timestamp, "\"timestamp\"");
		
		MPSString message_validator = new MPSString();
		message_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 4096);
		message_validator.validate(operationType, message, "\"message\"");
		
		MPSString operation_type_validator = new MPSString();
		operation_type_validator.setConstraintCharSetRegEx(MPSConstants.GENERIC_CONSTRAINT,"[ a-zA-Z0-9_#.:@=-]+");
		operation_type_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 32);
		operation_type_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		operation_type_validator.validate(operationType, operation_type, "\"operation_type\"");
		
		MPSInt trap_id_validator = new MPSInt();
		trap_id_validator.validate(operationType, trap_id, "\"trap_id\"");
		
		MPSString history_validator = new MPSString();
		history_validator.setConstraintCharSetRegEx(MPSConstants.GENERIC_CONSTRAINT,"[ a-zA-Z0-9_#.:@=-]+");
		history_validator.validate(operationType, history, "\"history\"");
		
	}
500470
public Set<ConstraintViolation> validate() {
		Set<ConstraintViolation> errors = new LinkedHashSet<ConstraintViolation>();
		for (int record = 1; record <= 3; ++record) {
			errors.addAll(validate(record));
		}
		return errors;
	}
589573
function getResult (err) {
        var res = {
            valid: true,
            errors: []
        };

        if (err !== null) {
            res.valid = false;
            res.errors.push(err);
        }

        return res;
    }
1302445
protected void validate(String operationType) throws Exception
	{
		super.validate(operationType);

		MPSString svm_version_validator = new MPSString();
		svm_version_validator.validate(operationType, svm_version, "\"svm_version\"");
		
		MPSString xen_version_validator = new MPSString();
		xen_version_validator.validate(operationType, xen_version, "\"xen_version\"");
		
		MPSString xen_supplemental_pack_version_validator = new MPSString();
		xen_supplemental_pack_version_validator.validate(operationType, xen_supplemental_pack_version, "\"xen_supplemental_pack_version\"");
		
		MPSString ns_version_validator = new MPSString();
		ns_version_validator.validate(operationType, ns_version, "\"ns_version\"");
		
		MPSString br_version_validator = new MPSString();
		br_version_validator.validate(operationType, br_version, "\"br_version\"");
		
		MPSString suggestion_validator = new MPSString();
		suggestion_validator.setConstraintMaxStrLen(MPSConstants.GENERIC_CONSTRAINT, 512);
		suggestion_validator.setConstraintMinStrLen(MPSConstants.GENERIC_CONSTRAINT, 1);
		suggestion_validator.validate(operationType, suggestion, "\"suggestion\"");
		
		MPSString xen_hotfix_validator = new MPSString();
		xen_hotfix_validator.validate(operationType, xen_hotfix, "\"xen_hotfix\"");
		
		MPSString svm_recommendation_validator = new MPSString();
		svm_recommendation_validator.validate(operationType, svm_recommendation, "\"svm_recommendation\"");
		
		MPSString xen_recommendation_validator = new MPSString();
		xen_recommendation_validator.validate(operationType, xen_recommendation, "\"xen_recommendation\"");
		
		MPSString xen_supplemental_pack_recommendation_validator = new MPSString();
		xen_supplemental_pack_recommendation_validator.validate(operationType, xen_supplemental_pack_recommendation, "\"xen_supplemental_pack_recommendation\"");
		
		MPSString xen_hotfix_recommendation_validator = new MPSString();
		xen_hotfix_recommendation_validator.validate(operationType, xen_hotfix_recommendation, "\"xen_hotfix_recommendation\"");
		
		MPSString ns_recommendation_validator = new MPSString();
		ns_recommendation_validator.validate(operationType, ns_recommendation, "\"ns_recommendation\"");
		
		MPSString br_recommendation_validator = new MPSString();
		br_recommendation_validator.validate(operationType, br_recommendation, "\"br_recommendation\"");
		
	}
996858
private RunFailure getRunFailure(RootMethodRunResult runResult) {
        if (runResult == null || runResult.getRunFailures().size() == 0) {
            return null; // no failure
        }

        // multiple run failures in one test method are not supported yet
        return runResult.getRunFailures().get(0);
    }
841651
protected void validate(String operationType) throws Exception
	{
		super.validate(operationType);

		MPSString svm_version_validator = new MPSString();
		svm_version_validator.validate(operationType, svm_version, "\"svm_version\"");
		
		MPSString xen_version_validator = new MPSString();
		xen_version_validator.validate(operationType, xen_version, "\"xen_version\"");
		
		MPSString xen_supplemental_pack_version_validator = new MPSString();
		xen_supplemental_pack_version_validator.validate(operationType, xen_supplemental_pack_version, "\"xen_supplemental_pack_version\"");
		
		MPSString ns_version_validator = new MPSString();
		ns_version_validator.validate(operationType, ns_version, "\"ns_version\"");
		
		MPSString br_version_validator = new MPSString();
		br_version_validator.validate(operationType, br_version, "\"br_version\"");
		
		MPSString xen_hotfix_validator = new MPSString();
		xen_hotfix_validator.validate(operationType, xen_hotfix, "\"xen_hotfix\"");
		
		MPSString status_validator = new MPSString();
		status_validator.validate(operationType, status, "\"status\"");
		
		MPSInt status_code_validator = new MPSInt();
		status_code_validator.validate(operationType, status_code, "\"status_code\"");
		
	}
1084949
public <T> FluentValidator onEach(Collection<T> t, final Validator<T> v) {
        Preconditions.checkNotNull(v, "Validator should not be NULL");
        if (CollectionUtil.isEmpty(t)) {
            lastAddCount = 0;
        } else {
            List<ValidatorElement> elementList = CollectionUtil.transform(t, new Function<T, ValidatorElement>() {
                @Override
                public ValidatorElement apply(T elem) {
                    composeIfPossible(v, elem);
                    return new ValidatorElement(elem, v);
                }
            });
            lastAddCount = t.size();
            doAdd(new IterableValidatorElement(elementList));
        }

        return this;
    }
367896
public FluentValidator doValidate(ValidateCallback cb) {
        Preconditions.checkNotNull(cb, "ValidateCallback should not be NULL");
        if (validatorElementList.isEmpty()) {
            LOGGER.debug("Nothing to validate");
            return this;
        }
        context.setResult(result);

        LOGGER.debug("Start to validate through " + validatorElementList);
        long start = System.currentTimeMillis();
        try {
            GroupingHolder.setGrouping(groups);
            for (ValidatorElement element : validatorElementList.getAllValidatorElements()) {
                Object target = element.getTarget();
                Validator v = element.getValidator();
                try {
                    if (v.accept(context, target)) {
                        if (!v.validate(context, target)) {
                            result.setIsSuccess(false);
                            if (isFailFast) {
                                break;
                            }
                        }
                    }
                } catch (Exception e) {
                    try {
                        v.onException(e, context, target);
                        cb.onUncaughtException(v, e, target);
                    } catch (Exception e1) {
                        if (LOGGER.isDebugEnabled()) {
                            LOGGER.error(v + " onException or onUncaughtException throws exception due to " + e1
                                    .getMessage(), e1);
                        }
                        throw new RuntimeValidateException(e1);
                    }
                    if (LOGGER.isDebugEnabled()) {
                        LOGGER.error(v + " failed due to " + e.getMessage(), e);
                    }
                    throw new RuntimeValidateException(e);
                }
            }

            if (result.isSuccess()) {
                cb.onSuccess(validatorElementList);
            } else {
                cb.onFail(validatorElementList, result.getErrors());
            }
        } finally {
            GroupingHolder.clean();
            int timeElapsed = (int) (System.currentTimeMillis() - start);
            LOGGER.debug("End to validate through" + validatorElementList + " costing " + timeElapsed + "ms with "
                    + "isSuccess=" + result.isSuccess());
            result.setTimeElapsed(timeElapsed);
        }
        return this;
    }
426733
private void validateResource(List<ValidationMessage> errors, Element resource, Element element, StructureDefinition profile, IdStatus idstatus, NodeStack stack) throws FHIRException, FHIRException {
		assert stack != null;
		assert resource != null;

		// getting going - either we got a profile, or not.
		boolean ok = true;
		if (ok) {
			String resourceName = element.getType();
			if (profile == null) {
				long t = System.nanoTime();
				profile = context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/" + resourceName);
				sdTime = sdTime + (System.nanoTime() - t);
				ok = rule(errors, IssueType.INVALID, element.line(), element.col(), stack.addToLiteralPath(resourceName), profile != null, "No profile found for resource type '" + resourceName + "'");
			} else {
				String type = profile.getKind() == StructureDefinitionKind.LOGICAL ? profile.getId() : profile.hasBaseType() && profile.getDerivation() == TypeDerivationRule.CONSTRAINT ? profile.getBaseType() : profile.getName();
				// special case: we have a bundle, and the profile is not for a bundle. We'll try the first entry instead 
				if (!type.equals(resourceName) && resourceName.equals("Bundle")) {
					Element first = getFirstEntry(element);
					if (first != null && first.getType().equals(type)) {
						element = first;
						resourceName = element.getType();
						idstatus = IdStatus.OPTIONAL; // why?
					}
				}
				ok = rule(errors, IssueType.INVALID, -1, -1, stack.getLiteralPath(), type.equals(resourceName),
						"Specified profile type was '" + type + "', but found type '" + resourceName + "'");
			}
		}

		if (ok) {
			if (idstatus == IdStatus.REQUIRED && (element.getNamedChild("id") == null))
				rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), false, "Resource requires an id, but none is present");
			else if (idstatus == IdStatus.PROHIBITED && (element.getNamedChild("id") != null))
				rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), false, "Resource has an id, but none is allowed");
			start(errors, resource, element, profile, stack); // root is both definition and type
		}
	}
254087
public AppValidator failsWith(String expectedFailure) {
        stringsToFind.add(expectedFailure);
        stringsToFind.add(APP_FAIL_CODE);
        server.addIgnoredErrors(Collections.singletonList(expectedFailure));
        return this;
    }