验证是否为英文字母 、数字和下划线

@param <T> 字符串类型
@param value 值
@param errorMsg 验证错误的信息
@return 验证后的值
@throws ValidateException 验证异常
19859
public static <T extends CharSequence> T validateGeneral(T value, String errorMsg) throws ValidateException {
		if (false == isGeneral(value)) {
			throw new ValidateException(errorMsg);
		}
		return value;
	}
139751
public TextInputDialogBuilder setValidationPattern(final Pattern pattern, final String errorMessage) {
        return setValidator(new TextInputDialogResultValidator() {
            @Override
            public String validate(String content) {
                Matcher matcher = pattern.matcher(content);
                if(!matcher.matches()) {
                    if(errorMessage == null) {
                        return "Invalid input";
                    }
                    return errorMessage;
                }
                return null;
            }
        });
    }
707880
public static ValueVo getErrorVo(String errorMsg) {

        ValueVo confItemVo = new ValueVo();
        confItemVo.setStatus(Constants.NOTOK);
        confItemVo.setValue("");
        confItemVo.setMessage(errorMsg);

        return confItemVo;
    }
26901
public static <T extends CharSequence> T validateMobile(T value, String errorMsg) throws ValidateException {
		if (false == isMobile(value)) {
			throw new ValidateException(errorMsg);
		}
		return value;
	}
1290932
public void validate(String path, String exceptionMessagePrefix) {
    if (!matches(path)) {
      throw new ValidationException(
          String.format(
              "%s: Parameter \"%s\" must be in the form \"%s\"",
              exceptionMessagePrefix, path, this.toString()));
    }
  }
87506
public FormInputValidator valueLesserThan (VisValidatableTextField field, String errorMsg, float value) {
		return valueLesserThan(field, errorMsg, value, false);
	}
163501
public static String buildValueMismatchErrorMessage(String baseMessage, Object controlValue, Object actualValue) {
        return baseMessage + ", expected '" + controlValue + "' but was '" + actualValue + "'";
    }
1188395
public static FormValidation validateBase64(String value, boolean allowWhitespace, boolean allowEmpty, String errorMessage) {
        try {
            String v = value;
            if(!allowWhitespace) {
                if(v.indexOf(' ')>=0 || v.indexOf('\n')>=0)
                    return error(errorMessage);
            }
            v=v.trim();
            if(!allowEmpty && v.length()==0)
                return error(errorMessage);

            Base64.getDecoder().decode(v.getBytes(StandardCharsets.UTF_8));
            return ok();
        } catch (IllegalArgumentException e) {
            return error(errorMessage);
        }
    }
895947
private void validateMessageForNull(Message msg) throws MessageFormatException {

        // if the supplied message is null, throw a jms MessageFormatException.
        if (msg == null) {
            throw (MessageFormatException) JmsErrorUtils.newThrowable(
                                                                      MessageFormatException.class,
                                                                      "INVALID_VALUE_CWSIA0068",
                                                                      new Object[] { "message", null },
                                                                      tc);
        }
    }
1355239
public static <T> T validateNotNull(T value, String errorMsgTemplate, Object... params) throws ValidateException {
		if (isNull(value)) {
			throw new ValidateException(errorMsgTemplate, params);
		}
		return value;
	}
357613
public void addError(I_CmsXmlContentValue value, String message) {

        m_hasErrors = true;
        Locale locale = value.getLocale();
        Map<String, String> localeErrors = getLocalIssueMap(m_errors, locale);
        localeErrors.put(value.getPath(), message);

        if (LOG.isDebugEnabled()) {
            LOG.debug(
                Messages.get().getBundle().key(Messages.LOG_XMLCONTENT_VALIDATION_ERR_2, value.getPath(), message));
        }
    }
52130
public static FormValidation validateRequired(String value) {
        if (Util.fixEmptyAndTrim(value) == null)
            return error(Messages.FormValidation_ValidateRequired());
        return ok();
    }
943911
public static function validate($value, $maxLen, $errorMessage)
    {
        if (mb_strlen($value, 'UTF-8') <= $maxLen) {
            return true;
        }
        throw new DomainError($errorMessage);
    }
142323
protected void validateRegex(String field, String regExpression, String errorKey, String errorMessage) {
		validateRegex(field, regExpression, true, errorKey, errorMessage);
	}
731477
public function validateDateTime($value, $errorMessage, $errorField = null)
    {
        if (!strtotime($value)) {
            $this->error($errorMessage);
            $this->_errorFields[] = $errorField;
        }
    }
722465
private String generateInvalidErrorMessage(Object[] enumValues, String testValue)
    {
        StringBuffer errorMessage = new StringBuffer("Unable to convert value [" + testValue + "].");

        errorMessage.append(" Allowed values are (case insensitive) ");

        StringBuffer valueList = new StringBuffer();

        int index = 1;
        for (Object enumValue : enumValues) {
            if (valueList.length() > 0) {
                if (++index == enumValues.length) {
                    valueList.append(" or ");
                } else {
                    valueList.append(", ");
                }
            }

            valueList.append('"');
            valueList.append(enumValue);
            valueList.append('"');
        }

        errorMessage.append(valueList);
        errorMessage.append('.');

        return errorMessage.toString();
    }
408903
@Override
    public ValidationResult validate(Object value) {
        if (value == null || value instanceof String) {
            return new ValidationResult.ValidationPassed();
        } else {
            return new ValidationResult.ValidationFailed("Value \"" + value + "\" is not a valid string!");
        }
    }