Add IBAN validation
This commit is contained in:
@ -385,8 +385,8 @@ namespace WGneu.Windows {
|
||||
return true; // TODO
|
||||
}
|
||||
|
||||
private void InputTextChanged(TextBox input, Func<TextBox, ValidationResult> checker) {
|
||||
var res = checker(input);
|
||||
private void InputTextChanged(TextBox input, bool optional, Func<TextBox, bool, ValidationResult> checker) {
|
||||
var res = checker(input, optional);
|
||||
Valid[input] = res.IsValid;
|
||||
if (res.IsValid)
|
||||
Validator.SetInputValid(input);
|
||||
@ -395,8 +395,8 @@ namespace WGneu.Windows {
|
||||
UpdateButtons();
|
||||
}
|
||||
|
||||
private void InputLostFocus(TextBox input, Func<TextBox, ValidationResult> checker, string? msg) {
|
||||
var res = checker(input);
|
||||
private void InputLostFocus(TextBox input, bool optional, Func<TextBox, bool, ValidationResult> checker, string? msg) {
|
||||
var res = checker(input, optional);
|
||||
if (!res.IsValid)
|
||||
MessageBox.Show(res.ErrorContent.ToString(), msg ?? res.ErrorContent.ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
@ -406,27 +406,35 @@ namespace WGneu.Windows {
|
||||
}
|
||||
|
||||
private void PhoneNrInput_TextChanged(object sender, RoutedEventArgs e) {
|
||||
InputTextChanged((TextBox)sender, Validator.CheckPhoneNumber);
|
||||
InputTextChanged((TextBox)sender, true, Validator.CheckPhoneNumber);
|
||||
}
|
||||
|
||||
private void PhoneNrInput_LostFocus(object sender, RoutedEventArgs e) {
|
||||
InputLostFocus((TextBox)sender, Validator.CheckPhoneNumber, null);
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckPhoneNumber, null);
|
||||
}
|
||||
|
||||
private void EmailInput_TextChanged(object sender, RoutedEventArgs e) {
|
||||
InputTextChanged((TextBox)sender, Validator.CheckEmailAddress);
|
||||
InputTextChanged((TextBox)sender, true, Validator.CheckEmailAddress);
|
||||
}
|
||||
|
||||
private void EmailInput_LostFocus(object sender, RoutedEventArgs e) {
|
||||
InputLostFocus((TextBox)sender, Validator.CheckEmailAddress, null);
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckEmailAddress, null);
|
||||
}
|
||||
|
||||
private void IbanInput_TextChanged(object sender, RoutedEventArgs e) {
|
||||
InputTextChanged((TextBox)sender, true, Validator.CheckIban);
|
||||
}
|
||||
|
||||
private void IbanInput_LostFocus(object sender, RoutedEventArgs e) {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckIban, null);
|
||||
}
|
||||
|
||||
private void LfbisNrInput_TextChanged(object sender, RoutedEventArgs e) {
|
||||
InputTextChanged((TextBox)sender, Validator.CheckLfbisNr);
|
||||
InputTextChanged((TextBox)sender, true, Validator.CheckLfbisNr);
|
||||
}
|
||||
|
||||
private void LfbisNrInput_LostFocus(object sender, RoutedEventArgs e) {
|
||||
InputLostFocus((TextBox)sender, Validator.CheckLfbisNr, "Betriebsnummer ungültig");
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckLfbisNr, "Betriebsnummer ungültig");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user