Skip to content

Commit

Permalink
Validate user input for contact number
Browse files Browse the repository at this point in the history
  • Loading branch information
Buhle79 committed Jul 10, 2023
1 parent 9435c1a commit d606128
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions yal/tests/test_pleasecallme.py
Original file line number Diff line number Diff line change
Expand Up @@ -941,3 +941,13 @@ async def state_state_specify_msisdn_invalid_input_with_plus(tester: AppTester):
tester.assert_message(
"\n".join(["⚠️ Please type a valid cell phone number.", "Example _081234567_"])
)


@pytest.mark.asyncio
async def state_state_specify_msisdn_empty_input(tester: AppTester):
tester.setup_state("state_specify_msisdn")
await tester.user_input(None)
tester.assert_state("state_specify_msisdn")
tester.assert_message(
"\n".join(["⚠️ Please type a valid cell phone number.", "Example _081234567_"])
)
2 changes: 1 addition & 1 deletion yal/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def validator(value):

def phone_number_validator(error_text):
async def validator(value):
if value.startswith("+") or value.isdigit():
if value:
try:
normalise_phonenumber(value)
except ValueError as e:
Expand Down

0 comments on commit d606128

Please sign in to comment.