Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
68830845
Commit
68830845
authored
Aug 11, 2020
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
默认日期格式的支持
parent
8bcae95e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
4 deletions
+39
-4
CheckerHelper.java
.../main/java/com/yanzuoguang/util/helper/CheckerHelper.java
+39
-4
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/CheckerHelper.java
View file @
68830845
...
...
@@ -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
l
ength
* @param
maxL
ength
* @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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment