How to use the phone function in phone

To help you get started, we’ve selected a few phone examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Automattic / wp-calypso / client / lib / phone-validation / index.jsx View on Github external
if ( phoneNumber.search( /[a-z,A-Z]/ ) > -1 ) {
		return {
			error: 'phone_number_contains_letters',
			message: i18n.translate( 'Phone numbers cannot contain letters' ),
		};
	}

	if ( phoneNumber.search( /[^0-9,\+]/ ) > -1 ) {
		return {
			error: 'phone_number_contains_special_characters',
			message: i18n.translate( 'Phone numbers cannot contain special characters' ),
		};
	}

	// phone module validates mobile numbers
	if ( ! phone( phoneNumber ).length ) {
		return {
			error: 'phone_number_invalid',
			message: i18n.translate( 'That phone number does not appear to be valid' ),
		};
	}

	return {
		info: 'phone_number_valid',
		message: i18n.translate( 'Valid phone number' ),
	};
}
github RootBank / dinosure / pages / checkout / profile / cellphone.js View on Github external
const isCellphoneNumberValid = (value) => isValidNumber(parse(value, 'ZA')) && phone(value, 'ZAF').length > 0;
github siriwatknp / mui-treasury / src / brands / peapods / lib / PeaProfileEditor.js View on Github external
const onUserChange = field => event => {
    let { value } = event.target;
    if (field === 'privateAccount') {
      value = event.target.checked;
    }
    if (field === 'email') {
      setError({ ...error, email: value && !emailValidator.validate(value) });
    }
    if (field === 'phoneNumber') {
      const [formattedPhoneNumber] = phone(value);
      setError({ ...error, phoneNumber: value && !formattedPhoneNumber });
    }
    setUser({
      ...user,
      [field]: value,
    });
  };

phone

With a given country and phone number, validate and format the phone number to E.164 standard

MIT
Latest version published 9 days ago

Package Health Score

86 / 100
Full package analysis