Java Code Examples for org.apache.commons.validator.GenericValidator#maxLength()

The following examples show how to use org.apache.commons.validator.GenericValidator#maxLength() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GenericModelChecks.java    From openemm with GNU Affero General Public License v3.0 5 votes vote down vote up
public static boolean validateMaxLength(Object bean, Field field, ValidatorResults results, ValidatorAction action) {
	String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
	if (value == null) {
		return true;
	}
	int max = Integer.parseInt(field.getVarValue("maxlength"));

	boolean valid = GenericValidator.maxLength(value, max);
	results.add(field, action.getName(), valid, value);
	return valid;
}
 
Example 2
Source File: ValidateUtil.java    From primecloud-controller with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 桁数チェック
 *
 * @param value 入力チェック対象の値
 * @param minLength 最小桁数
 * @param maxLength 最大桁数
 * @param code 入力チェックエラー時のメッセージコード
 * @param params 入力チェックエラー時のメッセージパラメータ
 */
public static void lengthInRange(String value, int minLength, int maxLength, String code, Object[] params) {
    if (value != null) {
        if (GenericValidator.minLength(value, minLength) == false
                || GenericValidator.maxLength(value, maxLength) == false) {
            throw new AutoApplicationException(code, params);
        }
    }
}
 
Example 3
Source File: Validators.java    From sinavi-jfw with Apache License 2.0 2 votes vote down vote up
/**
 * 指定された文字列の長さが指定したサイズと等しいか、それよりも小さいかを検査します。
 * アルゴリズムは、{@link GenericValidator#maxLength(String, int)}を利用しています。
 * @param suspect 検査対象
 * @param size サイズ
 * @return GenericValidator#maxLength(String, int)の結果
 */
public static boolean maxLength(CharSequence suspect, int size) {
    return GenericValidator.maxLength(suspect.toString(), size);
}