ruma_identifiers_validation/room_id.rs
1use crate::{validate_id, Error};
2
3/// Validate a [room ID] as used by clients.
4///
5/// [room ID]: https://spec.matrix.org/latest/appendices/#room-ids
6pub fn validate(s: &str) -> Result<(), Error> {
7 validate_id(s, b'!')?;
8
9 // Since we cannot check the localpart, check at least the NUL byte.
10 if s.as_bytes().contains(&b'\0') {
11 return Err(Error::InvalidCharacters);
12 }
13
14 Ok(())
15}