Skip to content

Commit dc5040b

Browse files
marcellorinaldosalvatore-coppola
authored andcommitted
fix(ui): NPE on notEqualsIdentityName validators
Signed-off-by: Marcello Rinaldo Martina <martina.marcello.rinaldo@outlook.com>
1 parent 88fc742 commit dc5040b

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

bundles/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/validator/GwtValidators.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,13 @@ public static Validator<String> nonEmpty(final String message) {
9898
}
9999

100100
public static Validator<String> notEqualsIdentityName(final String identityName, final String message) {
101-
return new ValidatorWrapper<>(new PredicateValidator(v -> !v.equalsIgnoreCase(identityName), message), Priority.MEDIUM);
101+
return new ValidatorWrapper<>(new PredicateValidator(v -> {
102+
if (v == null) {
103+
return true;
104+
}
105+
106+
return !v.equalsIgnoreCase(identityName);
107+
}, message), Priority.MEDIUM);
102108
}
103109

104110
public static <T> Validator<T> notInList(final List<T> values, final String message) {

bundles/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/validator/PasswordStrengthValidators.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,13 @@ private static Validator<String> containsBothCases(final Messages messages) {
9090
private static Validator<String> requireDifferentNameAndPassword(final String identityName,
9191
final Messages messages) {
9292

93-
return new PredicateValidator(v -> !v.equalsIgnoreCase(identityName), messages.pwdNotEqualsUsername());
93+
return new PredicateValidator(v -> {
94+
if (v == null) {
95+
return true;
96+
}
97+
98+
return !v.equalsIgnoreCase(identityName);
99+
}, messages.pwdNotEqualsUsername());
94100
}
95101

96102
public interface Messages {

0 commit comments

Comments
 (0)