ruma_identifiers_validation/client_secret.rs
1use crate::Error;
2
3pub fn validate(s: &str) -> Result<(), Error> {
4 if s.len() > 255 {
5 return Err(Error::MaximumLengthExceeded);
6 } else if !s.chars().all(|c| c.is_alphanumeric() || ".=_-".contains(c)) {
7 return Err(Error::InvalidCharacters);
8 } else if s.is_empty() {
9 return Err(Error::Empty);
10 }
11
12 Ok(())
13}