ruma-identifiers-validation 0.12.0

Validation logic for ruma-common and ruma-macros
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::{Error, validate_id};

/// Validate a [room ID] as used by clients.
///
/// [room ID]: https://spec.matrix.org/latest/appendices/#room-ids
pub fn validate(s: &str) -> Result<(), Error> {
    validate_id(s, b'!')?;

    // Since we cannot check the localpart, check at least the NUL byte.
    if s.as_bytes().contains(&b'\0') {
        return Err(Error::InvalidCharacters);
    }

    Ok(())
}