mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-12 19:28:20 +00:00
Compare commits
1 commit
28e13f0192
...
cfb3d0a3b0
Author | SHA1 | Date | |
---|---|---|---|
![]() |
cfb3d0a3b0 |
2 changed files with 2 additions and 5 deletions
|
@ -178,7 +178,6 @@ fn read_file_to_config(path: &str) -> Result<Config, ConfigError> {
|
|||
if conf.config_version != 1 {
|
||||
return Err(ConfigError::UnsupportedVersionError);
|
||||
}
|
||||
conf.validate()?;
|
||||
Ok(conf)
|
||||
}
|
||||
|
||||
|
|
|
@ -3,16 +3,14 @@ use {
|
|||
regex::Regex,
|
||||
};
|
||||
|
||||
const REGEX_NAME: &str = r"^[a-zA-Z0-9._/-]*$";
|
||||
|
||||
pub fn validate_name(value: &str, _: &Config) -> garde::Result {
|
||||
if value.len() > 32 {
|
||||
return Err(garde::Error::new("name is longer than 32"));
|
||||
}
|
||||
|
||||
static RE: Lazy<Regex> = Lazy::new(|| Regex::new(REGEX_NAME).unwrap());
|
||||
static RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"/^[0-9A-Za-z_-]*$/g").unwrap());
|
||||
if !RE.is_match(value) {
|
||||
return Err(garde::Error::new("name must only contain a-zA-Z0-9._/-"));
|
||||
return Err(garde::Error::new("name must only contain 0-9A-Za-z_-"));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue