mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
Use validateIfNotEmpty
This commit is contained in:
parent
c011b3e95a
commit
3d72884eee
1 changed files with 13 additions and 10 deletions
|
@ -40,18 +40,21 @@ public final class InteracETransferValidator extends InputValidator {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public InteracETransferValidator() {
|
||||
super();
|
||||
emailValidator = new EmailValidator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValidationResult validate(String input) {
|
||||
if (input == null)
|
||||
return new ValidationResult(false, "input is null");
|
||||
ValidationResult result = validateIfNotEmpty(input);
|
||||
if (!result.isValid) {
|
||||
return result;
|
||||
} else {
|
||||
ValidationResult emailResult = emailValidator.validate(input);
|
||||
if (!emailResult.isValid)
|
||||
return validatePhoneNumber(input);
|
||||
if (emailResult.isValid)
|
||||
return emailResult;
|
||||
else
|
||||
return validatePhoneNumber(input);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -60,7 +63,6 @@ public final class InteracETransferValidator extends InputValidator {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private ValidationResult validatePhoneNumber(String input) {
|
||||
|
||||
// check for correct format and strip +, space and -
|
||||
if (input.matches("\\+?1[ -]?\\d{3}[ -]?\\d{3}[ -]?\\d{4}")) {
|
||||
input = input.replace("+", "");
|
||||
|
@ -73,8 +75,9 @@ public final class InteracETransferValidator extends InputValidator {
|
|||
if (inputAreaCode.compareTo(s) == 0)
|
||||
return new ValidationResult(true);
|
||||
}
|
||||
} else
|
||||
return new ValidationResult(false, "Invalid phone number format and not an email address");
|
||||
return new ValidationResult(false, "Non-Canadian area code");
|
||||
} else {
|
||||
return new ValidationResult(false, "Invalid phone number format and not an email address");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue