Skip to content

Commit

Permalink
[PLAT-14900] Exclude empty string from regex validation for AZUoption…
Browse files Browse the repository at this point in the history
…al 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
  • Loading branch information
Jethro-M committed Aug 14, 2024
1 parent 9d2b83a commit d50171b
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConfigureRegionFormValues>({
Expand Down

0 comments on commit d50171b

Please sign in to comment.