diff --git a/src/config.rs b/src/config.rs index 3fc90c5..2a6aacc 100644 --- a/src/config.rs +++ b/src/config.rs @@ -2,7 +2,7 @@ use crate::BunBunError; use dirs::{config_dir, home_dir}; use log::{debug, info, trace}; use serde::{ - de::{self, Deserializer, MapAccess, Visitor}, + de::{self, Deserializer, MapAccess, Unexpected, Visitor}, Deserialize, Serialize, }; use std::collections::HashMap; @@ -138,6 +138,20 @@ impl<'de> Deserialize<'de> for Route { } } + if let (Some(min_args), Some(max_args)) = (min_args, max_args) { + if min_args > max_args { + { + return Err(de::Error::invalid_value( + Unexpected::Other(&format!( + "argument count range {} to {}", + min_args, max_args + )), + &"a valid argument count range", + )); + } + } + } + let path = path.ok_or_else(|| de::Error::missing_field("path"))?; Ok(Route { route_type: get_route_type(&path),