From f72f86d8aee612e9cdc48661efa4d5e112be0400 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Fri, 14 Mar 2025 18:48:34 -0500 Subject: [PATCH] Create management portal in Flutter #39 --- web/repertory/lib/helpers.dart | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/web/repertory/lib/helpers.dart b/web/repertory/lib/helpers.dart index b5808937..c250b089 100644 --- a/web/repertory/lib/helpers.dart +++ b/web/repertory/lib/helpers.dart @@ -32,6 +32,16 @@ final Validator noRestrictedChars = (value) { // ignore: prefer_function_declarations_over_variables final Validator notEmptyValidator = (value) => value.isNotEmpty; +// ignore: prefer_function_declarations_over_variables +final Validator portIsValid = (value) { + int? intValue = int.tryParse(value); + if (intValue == null) { + return false; + } + + return (intValue > 0 && intValue < 65536); +}; + // ignore: prefer_function_declarations_over_variables final Validator trimNotEmptyValidator = (value) => value.trim().isNotEmpty; @@ -112,25 +122,19 @@ List getSettingValidators(String settingPath) { case 'HostConfig.ApiPassword': return [notEmptyValidator]; case 'HostConfig.ApiPort': - return [ - (value) { - int? intValue = int.tryParse(value); - if (intValue == null) { - return false; - } - - return (intValue > 0 && intValue < 65536); - }, - createUriValidator(host: 'localhost'), - ]; + return [portIsValid]; case 'HostConfig.HostNameOrIp': return createHostNameOrIpValidators(); case 'HostConfig.Protocol': return [(value) => constants.protocolTypeList.contains(value)]; + case 'RemoteConfig.ApiPort': + return [notEmptyValidator, portIsValid]; case 'RemoteConfig.EncryptionToken': return [notEmptyValidator]; case 'RemoteConfig.HostNameOrIp': return createHostNameOrIpValidators(); + case 'RemoteMount.ApiPort': + return [notEmptyValidator, portIsValid]; case 'RemoteMount.EncryptionToken': return [notEmptyValidator]; case 'RemoteMount.HostNameOrIp':