diff --git a/dao/src/main/java/org/thingsboard/server/dao/service/Validator.java b/dao/src/main/java/org/thingsboard/server/dao/service/Validator.java
index 77f81d639f..16454e5914 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/service/Validator.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/service/Validator.java
@@ -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 String string. If string is invalid than throw
+ * IncorrectParameterException exception
+ *
+ * @param val the value
+ * @param errorMessageFunction the error message function that apply value
+ */
+ public static void validateString(String val, Function errorMessageFunction) {
+ if (val == null || val.isEmpty()) {
+ throw new IncorrectParameterException(errorMessageFunction.apply(val));
+ }
+ }
/**
* This method validate long value. If value isn't positive than throw