|
|
|
@ -27,6 +27,7 @@ import org.thingsboard.server.dao.exception.IncorrectParameterException; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.UUID; |
|
|
|
import java.util.function.Function; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
public class Validator { |
|
|
|
@ -59,6 +60,18 @@ public class Validator { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
* This method validate <code>String</code> string. If string is invalid than throw |
|
|
|
* <code>IncorrectParameterException</code> exception |
|
|
|
* |
|
|
|
* @param val the value |
|
|
|
* @param errorMessageFunction the error message function that apply value |
|
|
|
*/ |
|
|
|
public static void validateString(String val, Function<String, String> errorMessageFunction) { |
|
|
|
if (val == null || val.isEmpty()) { |
|
|
|
throw new IncorrectParameterException(errorMessageFunction.apply(val)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* This method validate <code>long</code> value. If value isn't positive than throw |
|
|
|
|