(ctx: &mut ValidationContext, name: &str)
| 198 | } |
| 199 | |
| 200 | fn validate_option_name(ctx: &mut ValidationContext, name: &str) { |
| 201 | if name.chars().count() > 42 { |
| 202 | ctx.push_field_error("name", "name can be max 42 characters long".to_string()); |
| 203 | } |
| 204 | |
| 205 | lazy_static! { |
| 206 | static ref RE: Regex = Regex::new(r#"^[\w_-]*$"#).unwrap(); |
| 207 | } |
| 208 | if !RE.is_match(name) { |
| 209 | ctx.push_field_error( |
| 210 | "name", |
| 211 | "name can only contain 'word characters', '-' and '_'".to_string(), |
| 212 | ); |
| 213 | } |
| 214 | } |
no test coverage detected