fn validate_name(name: String, meta: &Bucket<NameMeta>) -> Result<String, ContractError> {
    // If the load doesn't error out, that means it found the input name
    if meta.load(name.as_bytes()).is_ok() {
        return ContractError::NameRegistered { name }.to_result();
    }
    // Ensures that the given name is all lowercase and has no special characters or spaces
    // Note: This would be a great place to have a regex, but the regex cargo itself adds 500K to
    // the file size after optimization, excluding it as an option
    if name.is_empty()
        || name
            .chars()
            .any(|char| !char.is_alphanumeric() || (!char.is_lowercase() && !char.is_numeric()))
    {
        return ContractError::InvalidNameFormat { name }.to_result();
    }
    Ok("successful validation".into())
}
/// Validates that a name can be added.  Makes the following checks:
/// - The name is not already registered. Core validation to ensure duplicate registrations cannot occur
/// - The name is all lowercase and does not contain special characters. Ensures all names are easy to recognize.
Validates that a name can be added.  Makes the following checks:
The name is not already registered. Core validation to ensure duplicate registrations cannot occur
The name is all lowercase and does not contain special characters. Ensures all names are easy to recognize.
Validates that a name can be added . Makes the following checks : The name is not already registered . Core validation to ensure duplicate registrations cannot occur The name is all lowercase and does not contain special characters . Ensures all names are easy to recognize .
fn validate_name(name: String, meta: &Bucket<NameMeta>) -> Result<String, ContractError> {
    // If the load doesn't error out, that means it found the input name
    if meta.load(name.as_bytes()).is_ok() {
        return ContractError::NameRegistered { name }.to_result();
    }
    // Ensures that the given name is all lowercase and has no special characters or spaces
    // Note: This would be a great place to have a regex, but the regex cargo itself adds 500K to
    // the file size after optimization, excluding it as an option
    if name.is_empty()
        || name
            .chars()
            .any(|char| !char.is_alphanumeric() || (!char.is_lowercase() && !char.is_numeric()))
    {
        return ContractError::InvalidNameFormat { name }.to_result();
    }
    Ok("successful validation".into())
}
fn validate_name ( name : String , meta : & Bucket < NameMeta > ) -> Result < String , ContractError > { // If the load doesn't error out, that means it found the input name if meta . load ( name . as_bytes ( ) ) . is_ok ( ) { return ContractError :: NameRegistered { name } . to_result ( ) ; } // Ensures that the given name is all lowercase and has no special characters or spaces // Note: This would be a great place to have a regex, but the regex cargo itself adds 500K to // the file size after optimization, excluding it as an option if name . is_empty ( ) || name . chars ( ) . any ( | char | ! char . is_alphanumeric ( ) || ( ! char . is_lowercase ( ) && ! char . is_numeric ( ) ) ) { return ContractError :: InvalidNameFormat { name } . to_result ( ) ; } Ok ( " " . into ( ) ) }
Validates that a name can be added.
Validates that a name can be added .
name
String
meta
&Bucket<NameMeta>