From 32855b0fea28e7d71de0970babb0ada645b4f83a Mon Sep 17 00:00:00 2001 From: James Holman Date: Fri, 31 May 2024 18:56:05 +1000 Subject: [PATCH] fix: linting --- .../place_order/dto/address.gleam | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/order_taking/place_order/dto/address.gleam b/src/order_taking/place_order/dto/address.gleam index 406f643..fb58d1b 100644 --- a/src/order_taking/place_order/dto/address.gleam +++ b/src/order_taking/place_order/dto/address.gleam @@ -40,18 +40,21 @@ pub fn to_address(dto: AddressDto) -> Result(compound_types.Address, String) { dto.address_line_1 |> string50.create("address_line_1"), ) - use address_line_2 <- try(case dto.address_line_2 { - Some(addr) -> string50.create_option(addr, "address_line_2") - None -> Ok(None) - }) - use address_line_3 <- try(case dto.address_line_2 { - Some(addr) -> string50.create_option(addr, "address_line_3") - None -> Ok(None) - }) - use address_line_4 <- try(case dto.address_line_2 { - Some(addr) -> string50.create_option(addr, "address_line_4") - None -> Ok(None) - }) + use address_line_2 <- try( + dto.address_line_2 + |> option.map(fn(addr) { string50.create_option(addr, "address_line_2") }) + |> option.unwrap(Ok(None)), + ) + use address_line_3 <- try( + dto.address_line_3 + |> option.map(fn(addr) { string50.create_option(addr, "address_line_3") }) + |> option.unwrap(Ok(None)), + ) + use address_line_4 <- try( + dto.address_line_4 + |> option.map(fn(addr) { string50.create_option(addr, "address_line_4") }) + |> option.unwrap(Ok(None)), + ) use city <- try(dto.city |> string50.create("city")) use zip_code <- try(dto.zip_code |> zip_code.create("zip_code"))