Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Validation for Phone Numbers #590

Conversation

kasperbirch1
Copy link
Contributor

Link to issue

https://reload.atlassian.net/browse/DDFLSBP-200

Description

Add Validation for Phone Numbers from Denmark, Germany, and Greenland

  • Adjusted the input type to 'tel' to enhance phone number input handling.
  • Introduced new properties to TextInput to facilitate the validation of phone numbers, with specific enhancements:
  • pattern: A regex implemented to match phone numbers originating from Denmark, Germany, and Greenland.
  • title: used to display an error message in most browsers when the input does not adhere to the specified pattern.
  • Employed the same text for the placeholder as the error message to inform users about the accepted phone number formats.

pattern:

  • (+45|0045)[0-9]{8}: Matches a Denmark phone number: country code +45, followed by 8 digits.
  • (+49|0049)[0-9]{7,11}: Matches a German phone number: country code +49, followed by between 7 and 11 digits.
  • (+299|00299)[0-9]{6}: Matches a Greenland phone number: country code +299, followed by 6 digits.

Screenshot of the result

Skaermoptagelse.2023-10-11.kl.14.26.05.mov

- Adjusted the input type to 'tel' to enhance phone number input handling.
- Introduced new properties to `TextInput` to facilitate the validation of phone numbers, with specific enhancements:
- `pattern`: A regex implemented to match phone numbers originating from Denmark, Germany, and Greenland.
- `title`: used to display an error message in most browsers when the input does not adhere to the specified pattern.
- Employed the same text for the `placeholder` as the error message to inform users about the accepted phone number formats.

pattern:
* (\+45|0045)[0-9]{8}: Matches a Denmark phone number: country code +45, followed by 8 digits.
* (\+49|0049)[0-9]{7,11}: Matches a German phone number: country code +49, followed by between 7 and 11 digits.
* (\+299|00299)[0-9]{6}: Matches a Greenland phone number: country code +299, followed by 6 digits.
@kasperbirch1 kasperbirch1 changed the title Add Validation for Phone Numbers from Denmark, Germany, and Greenland Add Validation for Phone Numbers Oct 12, 2023
Copy link
Contributor

@kasperg kasperg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

Adding a why to the commit message about why we go for the more generic validation would be helpful.

@kasperbirch1 kasperbirch1 force-pushed the DDFLSBP-200-formvalidering-ingen-formvalidering-pa-felt-til-mobilnummer branch from 35a92d7 to e6a043a Compare October 13, 2023 06:48
Ensure phone numbers are 6-15 characters in length and either numeric or start with a '+'
This is to ensure that we can accept numbers from various sources while safeguarding against sending a number to the API that might cause an error.
@kasperbirch1 kasperbirch1 force-pushed the DDFLSBP-200-formvalidering-ingen-formvalidering-pa-felt-til-mobilnummer branch from e6a043a to ff59a21 Compare October 13, 2023 08:12
@kasperbirch1 kasperbirch1 merged commit f00b79c into danskernesdigitalebibliotek:develop Oct 13, 2023
10 checks passed
@kasperbirch1 kasperbirch1 deleted the DDFLSBP-200-formvalidering-ingen-formvalidering-pa-felt-til-mobilnummer branch October 13, 2023 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants