Commit 68830845 authored by yanzg's avatar yanzg

默认日期格式的支持

parent 8bcae95e
......@@ -27,6 +27,9 @@ public final class CheckerHelper {
public static final String PARAM_OVER_MAX_LENGTH = "param [%s] max length is %d";
public static final String PARAM_OVER_MAX_LENGTH_CH = "参数[%s]长度不能大于%d";
public static final String PARAM_OVER_MIN_LENGTH = "param [%s] min length is %d";
public static final String PARAM_OVER_MIN_LENGTH_CH = "参数[%s]长度不能小于%d";
public static final String PARAM_NOT_DATE_MONTH = "param [%s] must be yyyyMM";
public static final String PARAM_NOT_DATE_MONTH_CH = "参数[%s]的个是必须yyyyMM";
......@@ -64,6 +67,7 @@ public final class CheckerHelper {
.setEnglishChinese(PARAM_NOT_EMPTY_TIPS, PARAM_NOT_EMPTY_TIPS_CH)
.setEnglishChinese(PARAM_NOT_NUMBER, PARAM_NOT_NUMBER_CH)
.setEnglishChinese(PARAM_OVER_MAX_LENGTH, PARAM_OVER_MAX_LENGTH_CH)
.setEnglishChinese(PARAM_OVER_MIN_LENGTH, PARAM_OVER_MIN_LENGTH_CH)
.setEnglishChinese(PARAM_NOT_DATE_MONTH, PARAM_NOT_DATE_MONTH_CH)
.setEnglishChinese(PARAM_NOT_DATE_DAY, PARAM_NOT_DATE_DAY_CH)
.setEnglishChinese(PARAM_NOT_DATE, PARAM_NOT_DATE_CH)
......@@ -264,20 +268,51 @@ public final class CheckerHelper {
return this;
}
/**
* 长度检查
*
* @param paramName
* @param paramVal
* @param minLength
* @param
* @return
*/
public CheckerHelper checkLength(String paramName, String paramVal, int minLength) {
return checkLength(paramName, paramVal, minLength, 0);
}
/**
* 长度检查
*
* @param paramName
* @param paramVal
* @param length
* @param maxLength
* @return
*/
public CheckerHelper checkLength(String paramName, String paramVal, int length) {
public CheckerHelper checkLengthMax(String paramName, String paramVal, int maxLength) {
return checkLength(paramName, paramVal, 0, maxLength);
}
/**
* 长度检查
*
* @param paramName
* @param paramVal
* @param minLength
* @param maxLength
* @return
*/
public CheckerHelper checkLength(String paramName, String paramVal, int minLength, int maxLength) {
if (!isValid()) {
return this;
}
if (!StringHelper.isEmpty(paramVal) && length < paramVal.length()) {
this.checkResult = language.format(PARAM_OVER_MAX_LENGTH, paramName, length);
if (minLength > 0 && !StringHelper.isEmpty(paramVal) && minLength > paramVal.length()) {
this.checkResult = language.format(PARAM_OVER_MIN_LENGTH, paramName, minLength);
this.setValid(false);
}
if (maxLength > 0 && !StringHelper.isEmpty(paramVal) && maxLength < paramVal.length()) {
this.checkResult = language.format(PARAM_OVER_MAX_LENGTH, paramName, maxLength);
this.setValid(false);
}
return this;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment