diff --git a/exercises/03_ticket_v1/02_validation/src/lib.rs b/exercises/03_ticket_v1/02_validation/src/lib.rs index d7416eb..14ea5e2 100644 --- a/exercises/03_ticket_v1/02_validation/src/lib.rs +++ b/exercises/03_ticket_v1/02_validation/src/lib.rs @@ -17,7 +17,22 @@ impl Ticket { // as well as some `String` methods. Use the documentation of Rust's standard library // to find the most appropriate options -> https://doc.rust-lang.org/std/string/struct.String.html fn new(title: String, description: String, status: String) -> Self { - todo!(); + if status != "To-Do" && status != "In Progress" && status != "Done" { + panic!("Only `To-Do`, `In Progress`, and `Done` statuses are allowed") + } + if title.is_empty() { + panic!("Title cannot be empty") + } + if description.is_empty() { + panic!("Description cannot be empty") + } + if title.len() > 50 { + panic!("Title cannot be longer than 50 bytes") + } + if description.len() > 500 { + panic!("Description cannot be longer than 500 bytes") + } + Self { title, description,