fix(normalize): first name
This commit is contained in:
parent
aa4ea8cc4e
commit
b044dddbed
2 changed files with 9 additions and 1 deletions
|
@ -9,6 +9,12 @@ fn test_normalize_str() {
|
|||
|
||||
#[test]
|
||||
fn test_normalize_first_name() {
|
||||
let out = normalize_first_name("jpp jpp".to_string());
|
||||
assert_eq!(out, "Jpp-Jpp");
|
||||
|
||||
let out = normalize_first_name("jean pierre".to_string());
|
||||
assert_eq!(out, "Jean-Pierre");
|
||||
|
||||
let out = normalize_first_name("JEAN-PIERRE".to_string());
|
||||
assert_eq!(out, "Jean-Pierre");
|
||||
|
||||
|
|
|
@ -70,10 +70,12 @@ pub fn capitalize(s: &str) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
/// normalisation d'un prénom
|
||||
pub fn normalize_first_name(subject: String) -> String {
|
||||
subject
|
||||
.trim()
|
||||
.to_lowercase()
|
||||
.replace(' ', "")
|
||||
.replace(' ', "-")
|
||||
.split('-')
|
||||
.map(capitalize)
|
||||
.collect::<Vec<String>>()
|
||||
|
|
Loading…
Reference in a new issue