Validate a single POJO validate
@param pojo The POJO object to validate
@param name name of the field
334110
<T extends Validatable> void validatePOJO(final T pojo, final String name) {
    try {
      pojo.validate();
    } catch (final IllegalArgumentException e) {
      throw new IllegalArgumentException("Invalid " + name, e);
    }
  }
87123
public static boolean hasMethod(Object obj, String name) {
		if (obj == null)
			throw new NullPointerException("Object cannot be null");
		if (name == null)
			throw new NullPointerException("Method name cannot be null");

		Class<?> objClass = obj.getClass();

		for (Method method : objClass.getMethods()) {
			if (matchMethod(method, name))
				return true;
		}

		return false;
	}
285808
private static boolean validTemplateTypeName(String name) {
    return !name.isEmpty()
        && CharMatcher.javaLetterOrDigit().or(CharMatcher.is('_')).matchesAllOf(name);
  }
296498
protected boolean validate(T obj) throws ParameterException {
    if(constraints != null) {
      for(ParameterConstraint<? super T> cons : this.constraints) {
        cons.test(obj);
      }
    }
    return true;
  }
1275566
@Override
    public void validate() throws OpsGenieClientValidationException {
        super.validate();
        if (id == null && alias == null)
            throw OpsGenieClientValidationException.missingMultipleMandatoryProperty(OpsGenieClientConstants.API.ALIAS,
                    OpsGenieClientConstants.API.ID);
    }
966896
public void validateNull(Object object, String name, String message) {
        if (object != null) {
            addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.NULL_KEY.name(), name)));
        }
    }
195993
public void validateFalse(boolean value, String name) {
        validateFalse(value, name, messages.get(Validation.FALSE_KEY.name(), name));
    }
1119003
public function addValidation(string $name, string $validation): void{
        $this->validations[$name] = $validation;
    }
110692
@Override
    public void validate(final FacesContext context) {
        if (context == null) {
            throw new NullPointerException();
        }

        final Validator[] validators = getValidators();
        final Object value = getValue();

        if (!validateRequired(context, value)) {
            return;
        }

        if (validators == null) {
            return;
        }

        for (final Validator validator : validators) {
            try {
                validator.validate(context, this, value);
            }
            catch (final ValidatorException ve) {
                // If the validator throws an exception, we're
                // invalid, and we need to add a message
                setValid(false);
                FacesMessage message;
                final String validatorMessageString = getValidatorMessage();

                if (null != validatorMessageString) {
                    message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
                                validatorMessageString,
                                validatorMessageString);
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                }
                else {
                    final Collection<FacesMessage> messages = ve.getFacesMessages();
                    if (null != messages) {
                        message = null;
                        final String cid = getClientId(context);
                        for (final FacesMessage m : messages) {
                            context.addMessage(cid, m);
                        }
                    }
                    else {
                        message = ve.getFacesMessage();
                    }
                }
                if (message != null) {
                    final Sheet sheet = getSheet();
                    if (sheet == null) {
                        return;
                    }
                    context.addMessage(getClientId(context), message);
                    sheet.getInvalidUpdates().add(
                                new SheetInvalidUpdate(sheet.getRowKeyValue(context), sheet.getColumns().indexOf(this), this, value,
                                            message.getDetail()));

                }
            }
        }

    }
218768
static void validateHeaderName(CharSequence name) {
        if (name == null) {
            throw new NullPointerException("name");
        }
        if (name.length() == 0) {
            throw new IllegalArgumentException(
                    "name cannot be length zero");
        }
        // Since name may only contain ascii characters, for valid names
        // name.length() returns the number of bytes when UTF-8 encoded.
        if (name.length() > SPDY_MAX_NV_LENGTH) {
            throw new IllegalArgumentException(
                    "name exceeds allowable length: " + name);
        }
        for (int i = 0; i < name.length(); i ++) {
            char c = name.charAt(i);
            if (c == 0) {
                throw new IllegalArgumentException(
                        "name contains null character: " + name);
            }
            if (c >= 'A' && c <= 'Z') {
                throw new IllegalArgumentException("name must be all lower case.");
            }
            if (c > 127) {
                throw new IllegalArgumentException(
                        "name contains non-ascii character: " + name);
            }
        }
    }
909699
public void validate(final Node document) throws SchemaValidationException
	{
		try
		{
			final Validator validator = schema.newValidator();

			validator.validate(new DOMSource(document));
		}
		catch (SAXException | IOException e)
		{
			throw new SchemaValidationException(e.getMessage(), e);
		}
	}
351154
protected IStatus validateNameAgainstOtherSREs(String name) {
		IStatus nameStatus = SARLEclipsePlugin.getDefault().createOkStatus();
		if (isDuplicateName(name)) {
			nameStatus = SARLEclipsePlugin.getDefault().createStatus(IStatus.ERROR,
					ISREInstall.CODE_NAME,
					Messages.SREInstallWizard_1);
		} else {
			final IStatus status = ResourcesPlugin.getWorkspace().validateName(name, IResource.FILE);
			if (!status.isOK()) {
				nameStatus = SARLEclipsePlugin.getDefault().createStatus(IStatus.ERROR,
						ISREInstall.CODE_NAME,
						MessageFormat.format(Messages.SREInstallWizard_2, status.getMessage()));
			}
		}
		return nameStatus;
	}
10444
private void validateName(String name) throws DDFException {
    Boolean isNameExisted;
    try {
      this.getManager().getDDFByName(name);
      isNameExisted = true;
    } catch (DDFException e) {
      isNameExisted = false;
    }
    if(isNameExisted) {
      throw new DDFException(String.format("DDF with name %s already exists", name));
    }

    Pattern p = Pattern.compile("^[a-zA-Z0-9_-]*$");
    Matcher m = p.matcher(name);
    if(!m.find()) {
      throw new DDFException(String.format("Invalid name %s, only allow alphanumeric (uppercase and lowercase a-z, " +
          "numbers 0-9) and dash (\"-\") and underscore (\"_\")", name));
    }
  }
1083052
public static void validate(@NotNull Object bean) {
        Assert.notNull(bean, "bean不能为null");
        Set<ConstraintViolation<Object>> constraintViolations = validator.validate(bean);
        check(constraintViolations);
    }
1141413
private void validateBean(Object bean) throws PropertyException
    {
        if (getValidatorFactory() != null) {
            Validator validator = getValidatorFactory().getValidator();
            Set<ConstraintViolation<Object>> constraintViolations = validator.validate(bean);
            if (!constraintViolations.isEmpty()) {
                throw new PropertyException(
                    "Failed to validate bean: [" + constraintViolations.iterator().next().getMessage() + "]");
            }
        }
    }
208122
public static boolean isValidName( String name ) {
        if (name == null || name.length() == 0) return false;
        CharacterIterator iter = new StringCharacterIterator(name);
        char c = iter.first();
        if (!isValidNameStart(c)) return false;
        while (c != CharacterIterator.DONE) {
            if (!isValidName(c)) return false;
            c = iter.next();
        }
        return true;
    }
1247687
@com.fasterxml.jackson.annotation.JsonProperty("validationErrors")
    public void setValidationErrors(java.util.Collection<ValidationError> validationErrors) {
        if (validationErrors == null) {
            this.validationErrors = null;
            return;
        }

        this.validationErrors = new java.util.ArrayList<ValidationError>(validationErrors);
    }