From 8f860424f915746ac02b78fa42a201e4e2530a21 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Fri, 16 May 2025 03:11:05 +0300 Subject: [PATCH] battery: better validation for battery charge thresholds To accommodate vendors that use 0 to mean "charge immediately" or "disable start threshold," we modified the validation logic to allow start to be 0 *as long as* start is less than stop and stop is less than OR equal to 100 --- src/config/types.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config/types.rs b/src/config/types.rs index 7de13b7..10e0a9c 100644 --- a/src/config/types.rs +++ b/src/config/types.rs @@ -11,9 +11,9 @@ pub struct BatteryChargeThresholds { impl BatteryChargeThresholds { pub fn new(start: u8, stop: u8) -> Result { - if start == 0 || stop == 0 { + if stop == 0 { return Err(ConfigError::ValidationError( - "Thresholds must be greater than 0%".to_string(), + "Stop threshold must be greater than 0%".to_string(), )); } if start >= stop {