Cht-core: Gateway number validation is too strict

Created on 5 Aug 2019  路  10Comments  路  Source: medic/cht-core

Describe the bug
With introduction of Africa's talking integration, we can now use a short code e.g 42341 as the gateway phone number. This is configurable in the app settings uploaded to the instance but the UI validates against a value that is not a valid phone number.

To Reproduce
Steps to reproduce the behavior:

  1. Navigate to the admin settings page on the webapp ideally running v3.6.0 and above as this is the version we expect integration to SMS aggregator AT to work.
  2. Input a candidate short code in the Gateway Phone Number text field e.g 42341
  3. Click submit to save.
  4. You should observe the follow validation message: _This is number where mobile reporters should send their reports. It is also the number they will receive messages from.Not a valid phone number._ hindering you from saving.

Expected behavior
Ability to set a short code as the gateway phone number. (Rename the label while at it maybe ?)

Screenshots
Screenshot from 2019-08-05 15-12-34

Environment

Help wanted 2 - Medium Bug

All 10 comments

As a workaround I think you can disable this validation as per the documentation.

@garethbowen what about adding two new options for phone validation:

  1. partial_with_shortcode
  2. full_with_shortcode

what do you think?

IMO the problem is that we use the same level of validation throughout the app. I think it should only be applied when typing in a user's phone number which we don't expect to be a shortcode.

If we added the new options you suggest then these would also apply when adding users or contacts and I don't think that's correct.

The easiest solution I can think of is to remove the validation from this field altogether. Alternatively we could hardcode this field to use the gentler form of validation which allows shortcodes rather than using the configured level of validation.

I had not realized that deactivating phone_number validation as per the documenation as suggested above would deactivate for all phone number fields until your latest comment @garethbowen. That being the case, then hardcoding this particular field to allow for shortcodes is the probably best way forward.

Ready for AT in 5864-gateway-number-validation

There are 3 issues with this one:
1 - Upon clicking submit, the gateway textbox adds a + sign before the short code like so
image

2 - There is another page where this gateway number is required: Configuration wizard, shouldn't we apply the same custom validation there as well :
image

3- The submit button hangs ...but this is also on master and was most probably introduced by #5381 . Will create a separate issue for that:
image

angular.js:15567 TypeError: Cannot read property 'replace' of undefined at ChildScope.$scope.submit (sms-settings.js:59) at fn (eval at compile (angular.js:16418), <anonymous>:2:138) at callback (angular.js:28951) at ChildScope.$eval (angular.js:19393) at ChildScope.$apply (angular.js:19492) at HTMLButtonElement.<anonymous> (angular.js:28955) at HTMLButtonElement.dispatch (jquery.js:5237) at HTMLButtonElement.elemData.handle (jquery.js:5044)

^ or would you prefer we re-open #5381 @garethbowen for number 3 above?

Raise a new issue I think - it's confusing when an issue is reopened when the code is already merged.

Ready for AT in 5864-gateway-number-validation

LGTM
Have opened a different issue for the submit button not working . #6117

Was this page helpful?
0 / 5 - 0 ratings