Adjusted phone formatting libraries. IO-483

This commit is contained in:
Patrick Fic
2021-02-02 16:19:22 -08:00
parent 809ba0934a
commit 0bbfb259c0
4 changed files with 16 additions and 15 deletions

View File

@@ -1,9 +1,10 @@
import i18n from "i18next";
import phone from "phone";
import parsePhoneNumber from "libphonenumber-js";
import React, { forwardRef } from "react";
import PhoneInput from "react-phone-input-2";
import "react-phone-input-2/lib/high-res.css";
import "./phone-form-item.styles.scss";
function FormItemPhone(props, ref) {
return (
<PhoneInput
@@ -23,9 +24,9 @@ export const PhoneItemFormatterValidation = (getFieldValue, name) => ({
if (!getFieldValue(name)) {
return Promise.resolve();
} else {
const p = phone(getFieldValue(name), "us");
const p2 = phone(getFieldValue(name), "ca");
if (p.length > 0 || p2.length > 0) {
const p = parsePhoneNumber(getFieldValue(name), "CA");
if (p) {
return Promise.resolve();
} else {
return Promise.reject(i18n.t("general.validation.invalidphone"));