src: Rename "V2" folders to just Wizard
This replaces all occurences of "CreateImageWizardV2" with just "CreateImageWizard" as it is the only version now.
This commit is contained in:
parent
b1e5a8c7c6
commit
4fb37c187e
93 changed files with 20 additions and 22 deletions
76
src/Components/CreateImageWizard/validators.ts
Normal file
76
src/Components/CreateImageWizard/validators.ts
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
import { Partition } from './steps/FileSystem/FileSystemConfiguration';
|
||||
|
||||
export const isAwsAccountIdValid = (awsAccountId: string | undefined) => {
|
||||
return (
|
||||
awsAccountId !== undefined &&
|
||||
/^\d+$/.test(awsAccountId) &&
|
||||
awsAccountId.length === 12
|
||||
);
|
||||
};
|
||||
|
||||
export const isAzureTenantGUIDValid = (azureTenantGUID: string) => {
|
||||
return (
|
||||
azureTenantGUID !== undefined &&
|
||||
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(
|
||||
azureTenantGUID
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
export const isAzureSubscriptionIdValid = (azureSubscriptionId: string) => {
|
||||
return (
|
||||
azureSubscriptionId !== undefined &&
|
||||
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(
|
||||
azureSubscriptionId
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
export const isAzureResourceGroupValid = (azureResourceGroup: string) => {
|
||||
return (
|
||||
azureResourceGroup !== undefined &&
|
||||
/^[-\w._()]+[-\w_()]$/.test(azureResourceGroup)
|
||||
);
|
||||
};
|
||||
|
||||
export const isGcpEmailValid = (gcpShareWithAccount: string | undefined) => {
|
||||
return (
|
||||
gcpShareWithAccount !== undefined &&
|
||||
/^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,12}$/i.test(gcpShareWithAccount) &&
|
||||
gcpShareWithAccount.length <= 253
|
||||
);
|
||||
};
|
||||
|
||||
export const isMountpointMinSizeValid = (minSize: string) => {
|
||||
return /^\d+$/.test(minSize) && parseInt(minSize) > 0;
|
||||
};
|
||||
|
||||
export const isBlueprintNameValid = (blueprintName: string) =>
|
||||
blueprintName !== undefined &&
|
||||
blueprintName.length >= 2 &&
|
||||
blueprintName.length <= 100 &&
|
||||
/\w+/.test(blueprintName);
|
||||
|
||||
export const isBlueprintDescriptionValid = (blueprintDescription: string) => {
|
||||
return blueprintDescription.length <= 250;
|
||||
};
|
||||
export const isFileSystemConfigValid = (partitions: Partition[]) => {
|
||||
const duplicates = getDuplicateMountPoints(partitions);
|
||||
return duplicates.length === 0;
|
||||
};
|
||||
export const getDuplicateMountPoints = (partitions: Partition[]): string[] => {
|
||||
const mountPointSet: Set<string> = new Set();
|
||||
const duplicates: string[] = [];
|
||||
if (!partitions) {
|
||||
return [];
|
||||
}
|
||||
for (const partition of partitions) {
|
||||
const mountPoint = partition.mountpoint;
|
||||
if (mountPointSet.has(mountPoint)) {
|
||||
duplicates.push(mountPoint);
|
||||
} else {
|
||||
mountPointSet.add(mountPoint);
|
||||
}
|
||||
}
|
||||
return duplicates;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue