Skip to main content

sanitize_model_name

Function sanitize_model_name 

Source
pub fn sanitize_model_name(name: &str) -> String
Expand description

Sanitize a model name for use as a filename.

§Rules

  • Removes or replaces invalid filename characters
  • Ensures the name is safe for use in file paths
  • Preserves alphanumeric characters, hyphens, underscores, and dots
  • Replaces invalid characters with underscores
  • Truncates to MAX_MODEL_NAME_LENGTH if needed

§Examples

use data_modelling_core::validation::input::sanitize_model_name;

assert_eq!(sanitize_model_name("my-model"), "my-model");
assert_eq!(sanitize_model_name("my/model"), "my_model");
assert_eq!(sanitize_model_name("my..model"), "my.model");