Skip to content

Validate disk size against image size on disk create form #1773

@david-crespo

Description

@david-crespo

On instance create, we validate the size of the boot disk against the size of the chosen image, and when you change the image, we update the size to be big enough for it if necessary.

// Imitate API logic: only require that the disk is big enough to fit the image
validate={(diskSizeGiB) => {
if (!image) return true
if (diskSizeGiB < image.size / GiB) {
const minSize = Math.ceil(image.size / GiB)
return `Must be as large as selected image (min. ${minSize} GiB)`
}
if (diskSizeGiB > MAX_DISK_SIZE_GiB) {
return `Can be at most ${MAX_DISK_SIZE_GiB} GiB`
}
}}

On the standalone disk create form, we don't do that, and we should.

<DiskSizeField name="size" control={form.control} />

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions