Skip to content

Commit

Permalink
Wizrad: add condition to useHostnameValidation in case of empty string
Browse files Browse the repository at this point in the history
this adds condition to useHostnameValidation in case of empty string
if user decide to delete the value in hostname field
  • Loading branch information
mgold1234 committed Feb 11, 2025
1 parent 3eda8e2 commit 32f8bba
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/Components/CreateImageWizard/utilities/useValidation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,22 @@ export function useHostnameValidation(): StepValidation {
const errorMessage =
'Invalid hostname. The hostname should be composed of up to 64 7-bit ASCII lower-case alphanumeric characters or hyphens forming a valid DNS domain name. It is recommended that this name contains only a single label, i.e. without any dots.';

let hostnameError = '';
let disabledNext = false;
if (!isHostnameValid(hostname)) {
return {
errors: {
hostname: errorMessage,
},
disabledNext: true,
};
hostnameError = errorMessage;
disabledNext = true;
} else if (!hostname) {
// Hack to keep the error message from flickering in create mode
hostnameError = 'default';
}
return { errors: {}, disabledNext: false };

return {
errors: {
hostname: hostnameError,
},
disabledNext: disabledNext,
};
}

export function useKernelValidation(): StepValidation {
Expand Down

0 comments on commit 32f8bba

Please sign in to comment.