WizardV2: filesystem mountpoint size validation

This commit is contained in:
Ondrej Ezr 2024-04-09 11:26:01 +02:00 committed by Klara Simickova
parent 561e82827e
commit 54d032e0f0
2 changed files with 9 additions and 4 deletions

View file

@ -37,6 +37,7 @@ import { ValidatedTextInput } from '../../ValidatedTextInput';
import {
getDuplicateMountPoints,
isFileSystemConfigValid,
isMountpointMinSizeValid,
} from '../../validators';
export type Partition = {
@ -180,8 +181,8 @@ type RowPropTypes = {
};
const normalizeSuffix = (rawSuffix: string) => {
const suffix = rawSuffix.replace(/^\/+/g, '')
return suffix.length > 0 ? '/' + suffix : ''
const suffix = rawSuffix.replace(/^\/+/g, '');
return suffix.length > 0 ? '/' + suffix : '';
};
const getPrefix = (mountpoint: string) => {
@ -377,8 +378,8 @@ const MinimumSize = ({ partition, units }: MinimumSizePropTypes) => {
return (
<ValidatedTextInput
ariaLabel="minimum partition size"
helperText=""
validator={() => true}
helperText="Must be larger than 0"
validator={isMountpointMinSizeValid}
value={convertToDisplayUnits(partition.min_size)}
type="text"
onChange={(event, minSize) => {

View file

@ -32,6 +32,10 @@ export const isGcpEmailValid = (gcpShareWithAccount: string | undefined) => {
);
};
export const isMountpointMinSizeValid = (minSize: string) => {
return /^\d+$/.test(minSize) && parseInt(minSize) > 0;
};
export const isBlueprintNameValid = (blueprintName: string) =>
blueprintName.length >= 2 &&
blueprintName.length <= 100 &&