Function validate_username

Source
pub fn validate_username(username: String) -> Result<bool, ContractError>
Expand description

Validates a username against specific criteria.

This function checks if a given username meets the following conditions:

  • It must contain at least three characters
  • It must only contain alphanumeric characters

§Arguments

  • username - A String representing the username to be validated.

§Returns

  • Result<bool, ContractError> - Returns Ok(true) if the username is valid, otherwise returns an Err with a ContractError detailing the reason for invalidity.

§Examples