Skip to content

Commit

Permalink
Merge pull request #220 from qccoders/phone-validation
Browse files Browse the repository at this point in the history
Remove spaces and characters from phone number validation
  • Loading branch information
wburklund authored Oct 3, 2018
2 parents f4ced45 + c5467d6 commit 3afd767
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/QCVOC.Api/Veterans/Data/DTO/VeteranEnrollRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class VeteranEnrollRequest
/// Gets or sets the primary phone number of the Veteran.
/// </summary>
[Required]
[Phone]
[RegularExpression(@"^[1-9][0-9]{9}$")]
public string PrimaryPhone { get; set; }

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion api/QCVOC.Api/Veterans/Data/DTO/VeteranUpdateRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class VeteranUpdateRequest
/// Gets or sets the primary phone number of the Veteran.
/// </summary>
[Required]
[Phone]
[RegularExpression(@"^[1-9][0-9]{9}$")]
public string PrimaryPhone { get; set; }

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion web/src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const validateEmail = (email) => {

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

Expand Down
2 changes: 1 addition & 1 deletion web/src/veterans/VeteranDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class VeteranDialog extends Component {
result.primaryPhone = 'The Primary Phone field is required.';
}
else if (!validatePhoneNumber(primaryPhone)) {
result.primaryPhone = 'Enter a valid phone number in the format (555) 555-5555.';
result.primaryPhone = 'Enter a valid phone number in the format \'555555555\'';
}

if ((email !== '' && email !== undefined) && !validateEmail(email)) {
Expand Down

0 comments on commit 3afd767

Please sign in to comment.