MCPcopy Create free account
hub / github.com/Botloader/botloader / check_plugin_name

Function check_plugin_name

components/validation/src/web.rs:619–637  ·  view source on GitHub ↗
(ctx: &mut ValidationContext, name: &str)

Source from the content-addressed store, hash-verified

617}
618
619fn check_plugin_name(ctx: &mut ValidationContext, name: &str) {
620 if name.chars().count() > 32 {
621 ctx.push_field_error("name", "name can be max 32 characters long".to_string());
622 }
623
624 if name.chars().count() < 3 {
625 ctx.push_field_error("name", "name can be minimum 3 characters long".to_string());
626 }
627
628 lazy_static! {
629 static ref RE: Regex = Regex::new(r#"^[\w_-]*$"#).unwrap();
630 }
631 if !RE.is_match(name) {
632 ctx.push_field_error(
633 "name",
634 "name can only contain 'a-z', '-' and '_'".to_string(),
635 );
636 }
637}
638
639fn check_script_name(ctx: &mut ValidationContext, name: &str) {
640 if name.chars().count() > 32 {

Callers 1

validateMethod · 0.85

Calls 2

countMethod · 0.80
push_field_errorMethod · 0.80

Tested by

no test coverage detected