Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display up-to-date error messages under text fields #5006

Merged
merged 1 commit into from
Jan 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.math.BigInteger;

import java.util.Objects;
import java.util.function.Function;

public class InputValidator {
Expand Down Expand Up @@ -65,6 +66,12 @@ public String toString() {
'}';
}

public boolean errorMessageEquals(ValidationResult other) {
if (this == other) return true;
if (other == null) return false;
return Objects.equals(errorMessage, other.errorMessage);
}

public interface Validator extends Function<String, ValidationResult> {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public InputTextField() {
if (newValue != null) {
resetValidation();
if (!newValue.isValid) {
if (!newValue.errorMessageEquals(oldValue)) { // avoid blinking
validate(); // ensure that the new error message replaces the old one
}
if (this.errorMessage != null) {
jfxValidationWrapper.applyErrorMessage(this.errorMessage);
} else {
Expand Down