From 977f3207cdc3c8281fbf6b21273780a4b28f65df Mon Sep 17 00:00:00 2001 From: yaswanth-deriv <121096908+yaswanth-deriv@users.noreply.github.com> Date: Wed, 15 Feb 2023 11:25:13 +0400 Subject: [PATCH] refactor: fix polynomial expression issue fix --- packages/components/src/components/numpad/numpad.jsx | 2 +- packages/shared/src/utils/files/file-uploader-utils.ts | 2 +- .../shared/src/utils/validation/declarative-validation-rules.ts | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/components/src/components/numpad/numpad.jsx b/packages/components/src/components/numpad/numpad.jsx index 7b638cfc3ffd..f35f74952d76 100644 --- a/packages/components/src/components/numpad/numpad.jsx +++ b/packages/components/src/components/numpad/numpad.jsx @@ -78,7 +78,7 @@ const Numpad = ({ if (String(default_value) === '0') { updateValue(concatenate(num, '')); } else { - const regex = /(?:\d+\.)(\d+)$/; + const regex = /(?:\d+\.)?(\d+)$/; const matches = regex.exec(default_value); if (matches !== null && is_float) { diff --git a/packages/shared/src/utils/files/file-uploader-utils.ts b/packages/shared/src/utils/files/file-uploader-utils.ts index 14baeac8eb6f..4687d6b04c62 100644 --- a/packages/shared/src/utils/files/file-uploader-utils.ts +++ b/packages/shared/src/utils/files/file-uploader-utils.ts @@ -40,7 +40,7 @@ export const truncateFileName = (file: TFile, limit: number) => { }; export const getFileExtension = (file: TFile) => { - const f = file?.type?.match(/[^/]+$/); + const f = file?.type?.match(/[^\/]+$/); return f && f[0]; }; diff --git a/packages/shared/src/utils/validation/declarative-validation-rules.ts b/packages/shared/src/utils/validation/declarative-validation-rules.ts index 3f52fffb194c..df1cbbcbcb74 100644 --- a/packages/shared/src/utils/validation/declarative-validation-rules.ts +++ b/packages/shared/src/utils/validation/declarative-validation-rules.ts @@ -24,6 +24,7 @@ export const validPostCode = (value: string) => value === '' || /^[A-Za-z0-9][A- export const validTaxID = (value: string) => /(?!^$|\s+)[A-Za-z0-9./\s-]$/.test(value); export const validPhone = (value: string) => /^\+?([0-9-]+\s)*[0-9-]+$/.test(value); // export const validLetterSymbol = (value: string) => /^[A-Za-z]+([a-zA-Z.' -])*[a-zA-Z.' -]+$/.test(value); +//Added regex constructor to make it as object export const validLetterSymbol = (value: string) => { const pattern = "^[A-Za-z]+([a-zA-Z.' -])*[a-zA-Z.' -]+$"; const regex = new RegExp(pattern);