Skip to content

Commit

Permalink
Merge pull request #28 from dlsc-software-consulting-gmbh/develop
Browse files Browse the repository at this point in the history
Added a property to make the phone number type optional for the valid…
  • Loading branch information
dlemmermann authored Dec 18, 2023
2 parents 6431d33 + 1d9c733 commit dbe5570
Showing 1 changed file with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ protected void layoutChildren(double x, double y, double w, double h) {
e164PhoneNumber.set(phoneNumberUtil.format(number, PhoneNumberUtil.PhoneNumberFormat.E164));
nationalPhoneNumber.set(phoneNumberUtil.format(number, PhoneNumberUtil.PhoneNumberFormat.NATIONAL));
internationalPhoneNumber.set(phoneNumberUtil.format(number, PhoneNumberUtil.PhoneNumberFormat.INTERNATIONAL));
valid.set(phoneNumberUtil.isValidNumber(number) && isExpectedTypeMatch(number));
valid.set(phoneNumberUtil.isValidNumber(number) && (isExpectedTypeMatch(number) || !isValidityCheckIncludesTypeCheck()));
setTooltip(new Tooltip(getE164PhoneNumber()));
} catch (NumberParseException e) {
parsingErrorType.set(e.getErrorType());
Expand Down Expand Up @@ -421,12 +421,40 @@ private synchronized void doCommitValue() {

private boolean updating = false;

private final BooleanProperty validityCheckIncludesTypeCheck = new SimpleBooleanProperty(this, "validityCheckIncludesTypeCheck", false);

public final boolean isValidityCheckIncludesTypeCheck() {
return validityCheckIncludesTypeCheck.get();
}

/**
* Determines whether the validity of the field requires a valid phone number type, e.g. when
* the expected type is "mobile" then the field will only be valid if the number is not just a
* valid number by itself, but it is definitely a "mobile" number.
*
* @return true if the type of the number is considered when doing the validity check
*/
public final BooleanProperty validityCheckIncludesTypeCheckProperty() {
return validityCheckIncludesTypeCheck;
}

public final void setValidityCheckIncludesTypeCheck(boolean validityCheckIncludesTypeCheck) {
this.validityCheckIncludesTypeCheck.set(validityCheckIncludesTypeCheck);
}

private final BooleanProperty liveFormatting = new SimpleBooleanProperty(this, "liveFormatting", false);

public final boolean isLiveFormatting() {
return liveFormatting.get();
}

/**
* A flag that determines whether the displayed text will be formatted while the user is
* still entering it or only when the user "commits" the value by typing the ENTER key or by
* moving the focus to another field.
*
* @return true if the field gets constantly formatted
*/
public final BooleanProperty liveFormattingProperty() {
return liveFormatting;
}
Expand Down

0 comments on commit dbe5570

Please sign in to comment.