public bool PersonDetailsValid(Person person, CountryCodes country) { switch (this.ValidateName(person.FirstName)) { case PersonNameValidationResultsEnum.NameBlank: throw new PersonNameInvalidException(PersonNameValidationResultsEnum.FirstNameBlank); case PersonNameValidationResultsEnum.NameTooLong: throw new PersonNameInvalidException(PersonNameValidationResultsEnum.FirstNameTooLong); } switch (this.ValidateName(person.LastName)) { case PersonNameValidationResultsEnum.NameBlank: throw new PersonNameInvalidException(PersonNameValidationResultsEnum.LastNameBlank); case PersonNameValidationResultsEnum.NameTooLong: throw new PersonNameInvalidException(PersonNameValidationResultsEnum.LastNameTooLong); } PhoneValidationResultEnum phoneValidationResult = ValidatePhoneNumber(person.Phone); if (phoneValidationResult != PhoneValidationResultEnum.NumberOk) { throw new PhoneNumberInvalidException(phoneValidationResult); } return(true); }
public void onNextButtonClicked(View v) { // validate phone number var validator = new PeopleDetailsValidater(); PhoneValidationResultEnum phoneValidationResult = validator.ValidatePhoneNumber(this._editTextPhoneNumber.Text); if (phoneValidationResult != PhoneValidationResultEnum.NumberOk) { // _textViewError.SetTextColor(Color.Red); int errorRes = 0; switch (phoneValidationResult) { case PhoneValidationResultEnum.InvalidCharacters: errorRes = Resource.String.pin_validation_bad_chars; break; case PhoneValidationResultEnum.InvalidFormat: errorRes = Resource.String.phone_validation_invalid_format; break; case PhoneValidationResultEnum.NullEntry: errorRes = Resource.String.phone_validation_null; break; case PhoneValidationResultEnum.NumberTooLong: errorRes = Resource.String.pin_validation_long; break; case PhoneValidationResultEnum.NumberTooShort: errorRes = Resource.String.pin_validation_short; break; } _textViewError.Visibility = ViewStates.Visible; _textViewError.Text = GetText(errorRes); //parent.ShowKeyboard(edtPhone); return; } _textViewError.Text = ""; _textViewError.Visibility = ViewStates.Invisible; //pass countryName, CountryCode and Phone Number to next screen Intent intent = new Intent(this, typeof(DeviceRegistrationStep3)); intent.PutExtra("Country", _countryName); intent.PutExtra("CountryCode", _countryCode); intent.PutExtra("PhoneNumber", _editTextPhoneNumber.Text); StartActivity(intent); }
public PhoneNumberInvalidException(PhoneValidationResultEnum validationResult) { this.ValidationResult = validationResult; }