{"record":{"id":"44e68bc21cc339df","repo":"pemistahl/grex","slug":"quantity-of-minimum-repetitions-must-be-greater-than-zero","errorCode":null,"errorMessage":"Quantity of minimum repetitions must be greater than zero","messagePattern":"Quantity of minimum repetitions must be greater than zero","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/builder.rs","lineNumber":188,"sourceCode":"        self.config.is_case_insensitive_matching = true;\n        self\n    }\n\n    /// Replaces non-capturing groups with capturing ones.\n    pub fn with_capturing_groups(&mut self) -> &mut Self {\n        self.config.is_capturing_group_enabled = true;\n        self\n    }\n\n    /// Specifies the minimum quantity of substring repetitions to be converted if\n    /// [`with_conversion_of_repetitions`](Self::with_conversion_of_repetitions) is set.\n    ///\n    /// If the quantity is not explicitly set with this method, a default value of 1 will be used.\n    ///\n    /// ⚠ Panics if `quantity` is zero.\n    pub fn with_minimum_repetitions(&mut self, quantity: u32) -> &mut Self {\n        if quantity == 0 {\n            panic!(\"{}\", MINIMUM_REPETITIONS_MESSAGE);\n        }\n        self.config.minimum_repetitions = quantity;\n        self\n    }\n\n    /// Specifies the minimum length a repeated substring must have in order to be converted if\n    /// [`with_conversion_of_repetitions`](Self::with_conversion_of_repetitions) is set.\n    ///\n    /// If the length is not explicitly set with this method, a default value of 1 will be used.\n    ///\n    /// ⚠ Panics if `length` is zero.\n    pub fn with_minimum_substring_length(&mut self, length: u32) -> &mut Self {\n        if length == 0 {\n            panic!(\"{}\", MINIMUM_SUBSTRING_LENGTH_MESSAGE);\n        }\n        self.config.minimum_substring_length = length;\n        self\n    }","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/pemistahl/grex/blob/99cc347707375e00514f938b76d885a201dfc110/src/builder.rs#L170-L206","documentation":"RegExpBuilder::with_minimum_repetitions panics with MINIMUM_REPETITIONS_MESSAGE when quantity is 0. A minimum repetition count of zero would make the 'repeat at least n times' conversion meaningless, so the configuration API rejects it eagerly. The default, if unset, is 1.","triggerScenarios":"Calling builder.with_minimum_repetitions(0), typically because the value came from an unvalidated CLI flag, config file, or arithmetic expression that underflowed.","commonSituations":"A --min-reps CLI argument defaulted to 0; parsing user config where an empty/absent value became 0; subtracting values and hitting zero.","solutions":["Pass a quantity >= 1; omit the call entirely to use the default of 1","Clamp the input (quantity.max(1)) before calling the method","Validate the config/CLI value at parse time and reject 0 with a clear user-facing error"],"exampleFix":"// before\nbuilder.with_minimum_repetitions(min_reps); // min_reps may be 0\n// after\nlet min_reps = min_reps.max(1);\nbuilder.with_minimum_repetitions(min_reps);","handlingStrategy":"validation","validationCode":"if min_reps == 0 { return Err(anyhow!(\"--min-reps must be >= 1\")); }\nbuilder.with_minimum_repetitions(min_reps);","typeGuard":null,"tryCatchPattern":"let b = std::panic::catch_unwind(|| { let mut b = RegExpBuilder::from(&cases); b.with_minimum_repetitions(q); b })\n    .map_err(|_| \"minimum repetitions must be > 0\".to_string());","preventionTips":["Clamp parsed numeric config with .max(1) before applying it","Reject zero at the CLI/config parsing layer with a user-facing message","Remember the default is 1 — omit the call when you do not need a custom value"],"tags":["panic","config","validation"],"backgroundTag":"invalid-config-value","analyzedSha":"99cc347707375e00514f938b76d885a201dfc110","analyzedAt":"2026-09-13T15:42:56.144Z","contentChangedAt":"2026-09-13T15:42:56.144Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}