(field: &str, globs: &[String], errors: &mut Vec<Value>)
| 251 | } |
| 252 | |
| 253 | fn validate_globs(field: &str, globs: &[String], errors: &mut Vec<Value>) { |
| 254 | for pattern in globs { |
| 255 | if pattern.trim().is_empty() { |
| 256 | errors.push(validation_error( |
| 257 | field, |
| 258 | &format!("{field} patterns must not be empty"), |
| 259 | )); |
| 260 | continue; |
| 261 | } |
| 262 | if let Err(err) = glob::Pattern::new(pattern) { |
| 263 | errors.push(validation_error( |
| 264 | field, |
| 265 | &format!("invalid glob pattern '{pattern}': {err}"), |
| 266 | )); |
| 267 | } |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | fn validation_error(field: &str, message: &str) -> Value { |
| 272 | json!({ "field": field, "message": message }) |
no test coverage detected