Update DiskManagement.schema.ts

This commit is contained in:
Jonathan Summers-Muir committed 2024-10-30 16:41:04 +08:00
1 parent ade968ed3b
commit 7b89ca8f0f
1 file changed
+16 -3
@@ -1,5 +1,11 @@
import { z } from 'zod'
import { DISK_LIMITS, DiskType, THROUGHPUT_RANGE, IOPS_RANGE } from './ui/DiskManagement.constants'
import {
DISK_LIMITS,
DiskType,
THROUGHPUT_RANGE,
IOPS_RANGE,
DISK_TYPE_LABELS,
} from './ui/DiskManagement.constants'
import {
calculateDiskSizeRequiredForIopsWithGp3,
calculateDiskSizeRequiredForIopsWithIo2,
@@ -132,10 +138,10 @@ export const CreateDiskStorageSchema = (defaultTotalSize: number) => {
if (throughput !== undefined) {
const maxThroughput = Math.min(0.25 * provisionedIOPS, 1000)
if (throughput < THROUGHPUT_RANGE[DiskType.GP3].min) {
if (throughput > THROUGHPUT_RANGE['gp3'].max) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: `Throughput must be at least 125 MiB/s`,
message: `Throughput can not exceed ${maxThroughput} MiB/s`,
path: ['throughput'],
})
}
@@ -147,6 +153,13 @@ export const CreateDiskStorageSchema = (defaultTotalSize: number) => {
path: ['throughput'],
})
}
if (throughput < THROUGHPUT_RANGE[DiskType.GP3].min) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: `Throughput must be at least 125 MiB/s`,
path: ['throughput'],
})
}
}
if (totalSize > DISK_LIMITS[DiskType.GP3].maxStorage) {