ruma_identifiers_validation/
server_signing_key_version.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::Error;

#[cfg_attr(feature = "compat-server-signing-key-version", allow(unused_variables))]
pub fn validate(s: &str) -> Result<(), Error> {
    #[cfg(not(feature = "compat-server-signing-key-version"))]
    {
        if s.is_empty() {
            return Err(Error::Empty);
        } else if !s.chars().all(|c| c.is_alphanumeric() || c == '_') {
            return Err(Error::InvalidCharacters);
        }
    }

    Ok(())
}