Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

384 B
Raw Blame
use flowy_error::ErrorCode;

#[derive(Debug)]
pub struct UserId(pub String);

impl UserId {
  pub fn parse(s: String) -> Result<UserId, ErrorCode> {
    let is_empty_or_whitespace = s.trim().is_empty();
    if is_empty_or_whitespace {
      return Err(ErrorCode::UserIdInvalid);
    }
    Ok(Self(s))
  }
}

impl AsRef<str> for UserId {
  fn as_ref(&self) -> &str {
    &self.0
  }
}