readDeviceId method
String
readDeviceId(
- CustomDevicesConfig customDevicesConfig, {
- String? description,
})
Implementation
String readDeviceId(
CustomDevicesConfig customDevicesConfig, {
String? description,
}) {
logger.info(
description ??
'Please enter the id you want to device to have. Must contain only alphanumeric or underscore characters. (example: pi)',
);
final id = inputWithValidation(
'Device Id:',
validator: (s) {
if (!RegExp(r'^\w+$').hasMatch(s.trim())) {
return 'Invalid input. Please try again.';
} else if (customDevicesConfig.isDuplicatedDeviceId(s.trim())) {
return 'Device with this id already exists.';
}
return null;
},
).trim();
logger.spaces();
return id;
}