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 17, 2025
1 parent 52c790b commit 54d0bd5
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/Components/CreateImageWizard/utilities/useValidation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,20 +196,26 @@ export function useFirstBootValidation(): StepValidation {

export function useHostnameValidation(): StepValidation {
const hostname = useAppSelector(selectHostname);

// Error message taken from hostname man page (`man 5 hostname`)
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) {
// Reset validation status when hostname is empty
hostnameError = 'default';
}
return { errors: {}, disabledNext: false };

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

export function useKernelValidation(): StepValidation {
Expand Down

0 comments on commit 54d0bd5

Please sign in to comment.