From d50171bf909087b3e591c0bd25e6a07a3343d640 Mon Sep 17 00:00:00 2001 From: Jethro Mak <88681329+Jethro-M@users.noreply.github.com> Date: Mon, 12 Aug 2024 16:05:10 -0400 Subject: [PATCH] [PLAT-14900] Exclude empty string from regex validation for AZUoptional fields Summary: The optional resource group fields for AZU providers have regex pattern validation. Since this field is option, we should be ignoring the field when it is empty. Test Plan: Verify with a name that fails the regex pattern validation (ex. `resourceGroup.`). An error message is expected. Verify with a name that passes the regex pattern validation (ex. `resourceGroup`). No error message is expected. Verify with no input in the optional resource group fields. No error message is expected. Reviewers: lsangappa, yshchetinin, rmadhavan Reviewed By: lsangappa Subscribers: yugaware Differential Revision: https://phorge.dev.yugabyte.com/D37249 --- .../configureRegion/ConfigureRegionModal.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/managed/ui/src/components/configRedesign/providerRedesign/forms/configureRegion/ConfigureRegionModal.tsx b/managed/ui/src/components/configRedesign/providerRedesign/forms/configureRegion/ConfigureRegionModal.tsx index a0375ec2d1df..0b650ccbe8ce 100644 --- a/managed/ui/src/components/configRedesign/providerRedesign/forms/configureRegion/ConfigureRegionModal.tsx +++ b/managed/ui/src/components/configRedesign/providerRedesign/forms/configureRegion/ConfigureRegionModal.tsx @@ -184,15 +184,19 @@ export const ConfigureRegionModal = ({ }), azuNetworkRGOverride: string().when([], { is: () => shouldExposeField.azuNetworkRGOverride && providerCode === ProviderCode.AZU, - then: string().matches( - RG_REGEX, - "Resource group names can only include alphanumeric, underscore, parentheses, hyphen, period (except at end)"), + then: string().matches(RG_REGEX, { + message: + 'Resource group names can only include alphanumeric, underscore, parentheses, hyphen, period (except at end)', + excludeEmptyString: true + }) }), azuRGOverride: string().when([], { is: () => shouldExposeField.azuRGOverride && providerCode === ProviderCode.AZU, - then: string().matches( - RG_REGEX, - "Resource group names can only include alphanumeric, underscore, parentheses, hyphen, period (except at end)"), + then: string().matches(RG_REGEX, { + message: + 'Resource group names can only include alphanumeric, underscore, parentheses, hyphen, period (except at end)', + excludeEmptyString: true + }) }) }); const formMethods = useForm({