public final class Validators extends Object
When you use the validator, the input parameters meet the meaning of the calling method and the validation passes, otherwise a ValidatorException is throw.
By default, all prompts are returned based on I18N_MAP. The default language is English. If you want a custom to throw a message, you can call the throwMessage method.
构造器和说明 |
---|
Validators() |
限定符和类型 | 方法和说明 |
---|---|
static Validation<String> |
contains(String c)
The input parameter must contain the string c. if yes, the check passes
|
static Validation<String> |
contains(String c,
String msg)
The input parameter must contain the string c. if yes, the check passes
|
static Validation<Integer> |
greaterThan(int min)
Determine if the input int parameter is greater than min. if yes, the check passes
|
static Validation<Integer> |
greaterThan(int min,
String msg)
Determine if the input int parameter is greater than min. if yes, the check passes
|
static Validation<String> |
isEmail()
Determine if the input parameter is a Email. if yes, the check passes
|
static Validation<String> |
isEmail(String msg)
Determine if the input parameter is a Email. if yes, the check passes.
|
static Validation<String> |
isURL()
Determine if the input parameter is a URL. if yes, the check passes
|
static Validation<String> |
isURL(String msg)
Determine if the input parameter is a URL. if yes, the check passes.
|
static Validation<String> |
length(int minSize,
int maxSize)
The length of the input string must be between minSize and maxSize. if yes, the check passes
|
static Validation<String> |
lessThan(int size)
The input string must be less than or equal to size. if yes, the check passes
|
static Validation<String> |
lessThan(int size,
String msg)
The input string must be less than or equal to size. if yes, the check passes
|
static Validation<Integer> |
lowerThan(int max)
Determine if the input int parameter is lower than max. if yes, the check passes
|
static Validation<Integer> |
lowerThan(int max,
String msg)
Determine if the input int parameter is lower than max. if yes, the check passes
|
static Validation<String> |
moreThan(int size)
The input string must be more than or equal to size. if yes, the check passes
|
static Validation<String> |
moreThan(int size,
String msg)
The input string must be more than or equal to size. if yes, the check passes
|
static Validation<String> |
notEmpty()
The input string is not empty. if yes, the check passes
|
static Validation<String> |
notEmpty(String msg)
The input string is not empty. if yes, the check passes
|
static <T> Validation<T> |
notNull()
The input object is not null. if yes, the check passes
|
static <T> Validation<T> |
notNull(String msg)
The input object is not null. if yes, the check passes
|
static Validation<Integer> |
range(int min,
int max)
Determine if the input int parameter is it in a range. if yes, the check passes
|
static void |
useChinese() |
public static void useChinese()
public static <T> Validation<T> notNull()
public static <T> Validation<T> notNull(String msg)
msg
- error message after verification failedpublic static Validation<String> notEmpty()
public static Validation<String> notEmpty(String msg)
msg
- error message after verification failedpublic static Validation<String> moreThan(int size)
size
- string sizepublic static Validation<String> moreThan(int size, String msg)
size
- string sizemsg
- error message after verification failedpublic static Validation<String> lessThan(int size)
size
- string sizepublic static Validation<String> lessThan(int size, String msg)
size
- string sizemsg
- error message after verification failedpublic static Validation<String> length(int minSize, int maxSize)
minSize
- string min sizemaxSize
- string max sizepublic static Validation<String> contains(String c)
c
- contained stringspublic static Validation<String> contains(String c, String msg)
c
- contained stringsmsg
- error message after verification failedpublic static Validation<Integer> lowerThan(int max)
max
- input must be < max numberpublic static Validation<Integer> lowerThan(int max, String msg)
max
- input must be < max numbermsg
- error message after verification failedpublic static Validation<Integer> greaterThan(int min)
min
- input must be > min numberpublic static Validation<Integer> greaterThan(int min, String msg)
min
- input must be > min numbermsg
- error message after verification failedpublic static Validation<Integer> range(int min, int max)
min
- input must be > min numbermax
- input must be < max numberpublic static Validation<String> isEmail()
public static Validation<String> isEmail(String msg)
msg
- error message after verification failedpublic static Validation<String> isURL()
public static Validation<String> isURL(String msg)
msg
- error message after verification failedCopyright © 2018. All rights reserved.