From 55686cc84483869a656d0f316be35d7928f1ef8d Mon Sep 17 00:00:00 2001 From: regexowl Date: Mon, 15 Jan 2024 16:47:17 +0100 Subject: [PATCH] V2Wizard: Improve validators Follow up to https://github.com/RedHatInsights/image-builder-frontend/pull/1548 This cleans up implementation for the AWS account ID ad GCP e-mail validators. --- src/Components/CreateImageWizardV2/validators.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/Components/CreateImageWizardV2/validators.ts b/src/Components/CreateImageWizardV2/validators.ts index d740673dd..ca1357f5f 100644 --- a/src/Components/CreateImageWizardV2/validators.ts +++ b/src/Components/CreateImageWizardV2/validators.ts @@ -1,21 +1,15 @@ export const isAwsAccountIdValid = (awsAccountId: string | undefined) => { - if ( + return ( awsAccountId !== undefined && /^\d+$/.test(awsAccountId) && awsAccountId.length === 12 - ) { - return true; - } - return false; + ); }; export const isGcpEmailValid = (gcpShareWithAccount: string | undefined) => { - if ( + return ( gcpShareWithAccount !== undefined && /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,12}$/.test(gcpShareWithAccount) && gcpShareWithAccount.length <= 253 - ) { - return true; - } - return false; + ); };