diff --git a/editoast/src/core/simulation.rs b/editoast/src/core/simulation.rs index 81a6eb89569..20f6fcbc059 100644 --- a/editoast/src/core/simulation.rs +++ b/editoast/src/core/simulation.rs @@ -112,13 +112,12 @@ impl PhysicsConsistParameters { } pub fn compute_max_speed(&self) -> f64 { - match self.max_speed { - Some(0.0) => self.traction_engine.max_speed, - Some(max_speed_parameter) => { + self.max_speed + .filter(|max_speed_parameter| *max_speed_parameter != 0.0) + .map(|max_speed_parameter| { f64::min(self.traction_engine.max_speed, max_speed_parameter) - } - None => self.traction_engine.max_speed, - } + }) + .unwrap_or(self.traction_engine.max_speed) } pub fn compute_startup_acceleration(&self) -> f64 { diff --git a/editoast/src/views/timetable/stdcm.rs b/editoast/src/views/timetable/stdcm.rs index 535e026fde6..26fd5d2eff6 100644 --- a/editoast/src/views/timetable/stdcm.rs +++ b/editoast/src/views/timetable/stdcm.rs @@ -125,13 +125,13 @@ pub struct STDCMRequestPayload { #[schema(value_type = Option, example = json!(["5%", "2min/100km"]))] margin: Option, /// Total mass of the consist in kg - #[validate(range(min = 1.0))] + #[validate(range(exclusive_min = 0.0))] total_mass: Option, /// Total length of the consist in meters - #[validate(range(min = 1.0))] + #[validate(range(exclusive_min = 0.0))] total_length: Option, /// Maximum speed of the consist in km/h - #[validate(range(min = 1.0))] + #[validate(range(exclusive_min = 0.0))] max_speed: Option, loading_gauge_type: Option, }