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.
This commit is contained in:
regexowl 2024-01-15 16:47:17 +01:00 committed by Lucas Garfield
parent 3ed2192358
commit 55686cc844

View file

@ -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;
);
};