Wizard: Add Hostname functionality

This adds a validated hostname input and new tests.
This commit is contained in:
regexowl 2024-12-11 09:54:16 +01:00 committed by Lucas Garfield
parent c98b7d9997
commit 5a514d1d04
7 changed files with 153 additions and 4 deletions

View file

@ -90,3 +90,12 @@ export const isNtpServerValid = (ntpServer: string) => {
/^([a-z0-9-]+)?(([.:/]{1,3}[a-z0-9-]+)){1,}$/.test(ntpServer)
);
};
export const isHostnameValid = (hostname: string) => {
if (hostname !== '') {
return /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$/.test(
hostname
);
}
return true;
};