Matthias Nott
2026-03-25 d6cf9469aa0462d1b8313cc85907176eee1214a2
lib/screens/settings_screen.dart
....@@ -158,6 +158,11 @@
158158 hintText: '192.168.1.100',
159159 ),
160160 keyboardType: TextInputType.url,
161
+ validator: (v) {
162
+ if (v == null || v.trim().isEmpty) return null;
163
+ final ip = RegExp(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$');
164
+ return ip.hasMatch(v.trim()) ? null : 'Enter a valid IP address';
165
+ },
161166 ),
162167 const SizedBox(height: 16),
163168
....@@ -171,6 +176,11 @@
171176 hintText: '10.8.0.1 (OpenVPN static IP)',
172177 ),
173178 keyboardType: TextInputType.url,
179
+ validator: (v) {
180
+ if (v == null || v.trim().isEmpty) return null;
181
+ final ip = RegExp(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$');
182
+ return ip.hasMatch(v.trim()) ? null : 'Enter a valid IP address';
183
+ },
174184 ),
175185 const SizedBox(height: 16),
176186
....@@ -198,6 +208,14 @@
198208 hintText: '8765',
199209 ),
200210 keyboardType: TextInputType.number,
211
+ validator: (v) {
212
+ if (v == null || v.trim().isEmpty) return 'Required';
213
+ final port = int.tryParse(v.trim());
214
+ if (port == null || port < 1 || port > 65535) {
215
+ return 'Port must be 1–65535';
216
+ }
217
+ return null;
218
+ },
201219 ),
202220 const SizedBox(height: 16),
203221
....@@ -210,6 +228,14 @@
210228 decoration: const InputDecoration(
211229 hintText: 'AA:BB:CC:DD:EE:FF',
212230 ),
231
+ validator: (v) {
232
+ if (v == null || v.trim().isEmpty) return null;
233
+ final mac = RegExp(
234
+ r'^[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}$');
235
+ return mac.hasMatch(v.trim())
236
+ ? null
237
+ : 'Enter a valid MAC address (AA:BB:CC:DD:EE:FF)';
238
+ },
213239 ),
214240 const SizedBox(height: 16),
215241