/// Validate primary key format.
/// Including one-letter primary key and two-letters compound key.
Validate primary key format.
Including one-letter primary key and two-letters compound key.
Validate primary key format . Including one - letter primary key and two - letters compound key .
fn validate_primary_key(key: String) -> Result<(), String> {
    if key.chars().all(|c| c.is_ascii_alphanumeric()) {
        if key.is_empty() || key.len() > 2 {
            return Err(String::from("Invalid key length"));
        }
        Ok(())
    } else {
        Err(String::from("Invalid primary key"))
    }
}
fn validate_primary_key ( key : String ) -> Result < ( ) , String > { if key . chars ( ) . all ( | c | c . is_ascii_alphanumeric ( ) ) { if key . is_empty ( ) || key . len ( ) > 2 { return Err ( String :: from ( " " ) ) ; } Ok ( ( ) ) } else { Err ( String :: from ( " " ) ) } }
Validate primary key format.
Validate primary key format .
key
String