Skip to content

Commit 3afd767

Browse files
authored
Merge pull request #220 from qccoders/phone-validation
Remove spaces and characters from phone number validation
2 parents f4ced45 + c5467d6 commit 3afd767

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

api/QCVOC.Api/Veterans/Data/DTO/VeteranEnrollRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class VeteranEnrollRequest
4949
/// Gets or sets the primary phone number of the Veteran.
5050
/// </summary>
5151
[Required]
52-
[Phone]
52+
[RegularExpression(@"^[1-9][0-9]{9}$")]
5353
public string PrimaryPhone { get; set; }
5454

5555
/// <summary>

api/QCVOC.Api/Veterans/Data/DTO/VeteranUpdateRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class VeteranUpdateRequest
4949
/// Gets or sets the primary phone number of the Veteran.
5050
/// </summary>
5151
[Required]
52-
[Phone]
52+
[RegularExpression(@"^[1-9][0-9]{9}$")]
5353
public string PrimaryPhone { get; set; }
5454

5555
/// <summary>

web/src/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const validateEmail = (email) => {
5050

5151
export const validatePhoneNumber = (phoneNumber) => {
5252
// eslint-disable-next-line
53-
var re = /\(\d{3}\) \d{3}-\d{4}/;
53+
var re = /^[1-9][0-9]{9}$/;
5454
return re.test(phoneNumber);
5555
}
5656

web/src/veterans/VeteranDialog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class VeteranDialog extends Component {
227227
result.primaryPhone = 'The Primary Phone field is required.';
228228
}
229229
else if (!validatePhoneNumber(primaryPhone)) {
230-
result.primaryPhone = 'Enter a valid phone number in the format (555) 555-5555.';
230+
result.primaryPhone = 'Enter a valid phone number in the format \'555555555\'';
231231
}
232232

233233
if ((email !== '' && email !== undefined) && !validateEmail(email)) {

0 commit comments

Comments
 (0)