return stringProperty1.getValueSafe().equals(stringProperty2.getValueSafe()) && isPasswordValid(stringProperty1.getValueSafe());
private BooleanBinding bindForValidity(boolean withConfirmation, TextField electionOfficer1Password, TextField electionOfficer2Password, Label errorMessage, Node confirmButton) {
BooleanBinding passwordsValid = Bindings.createBooleanBinding(
() -> withConfirmation ? arePasswordsEqualAndValid(electionOfficer1Password.textProperty(), electionOfficer2Password.textProperty()) : isPasswordValid(electionOfficer1Password.getText()),
electionOfficer1Password.textProperty(),
electionOfficer2Password.textProperty());
passwordsValid.addListener((observable, werePasswordsValid, arePasswordsValid) -> {
confirmButton.setDisable(!arePasswordsValid);
errorMessage.setVisible(!arePasswordsValid && withConfirmation);
});
return passwordsValid;
}
Unfortunately, I do not know how significant this issue is since you do not have a clear threat model (#17).