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

VBA Fields validation #5531

Merged
merged 10 commits into from
Oct 4, 2021
5 changes: 2 additions & 3 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ const CONST = {
TAX_ID_NUMBER: 9,
SSN: 4,
ZIP_CODE: 5,
PHONE_NUMBER: 15,
},
},
INCORPORATION_TYPES: {
Expand Down Expand Up @@ -420,12 +419,12 @@ const CONST = {
LARGE: 'large',
DEFAULT: 'default',
},

PHONE_MAX_LENGTH: 15,
REGEX: {
US_PHONE: /^\+1\d{10}$/,
DIGITS_AND_PLUS: /^\+?[0-9]*$/,
PHONE_E164_PLUS: /^\+?[1-9]\d{1,14}$/,
PHONE_WITH_SPECIAL_CHARS: /^[+]*[(]{0,1}[0-9]{1,3}[)]{0,1}[-\s\\./0-9]*$/,
PHONE_WITH_SPECIAL_CHARS: /^[+]*[(]{0,1}[0-9]{1,3}[)]{0,1}[-\s\\./0-9]{0,11}$/,
NON_ALPHA_NUMERIC: /[^A-Za-z0-9+]/g,
PO_BOX: /\b[P|p]?(OST|ost)?\.?\s*[O|o|0]?(ffice|FFICE)?\.?\s*[B|b][O|o|0]?[X|x]?\.?\s+[#]?(\d+)\b/,
ANY_VALUE: /^.+$/,
Expand Down
2 changes: 1 addition & 1 deletion src/libs/ValidationUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function isValidAge(date) {
* @returns {Boolean}
*/
function isValidPhoneWithSpecialChars(phoneNumber) {
return CONST.REGEX.PHONE_WITH_SPECIAL_CHARS.test(phoneNumber);
return CONST.REGEX.PHONE_WITH_SPECIAL_CHARS.test(phoneNumber) && phoneNumber.length <= CONST.PHONE_MAX_LENGTH;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ReimbursementAccount/CompanyStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class CompanyStep extends React.Component {
value={this.state.companyPhone}
placeholder={this.props.translate('companyStep.companyPhonePlaceholder')}
errorText={this.getErrorText('companyPhone')}
maxLength={CONST.BANK_ACCOUNT.MAX_LENGTH.PHONE_NUMBER}
maxLength={CONST.PHONE_MAX_LENGTH}

/>
<ExpensiTextInput
Expand Down