From 7c92898c8f0adb4a6014ce5f434a7d862a0cdc57 Mon Sep 17 00:00:00 2001 From: Mateus Cruz Date: Tue, 6 Feb 2024 01:47:46 -0300 Subject: add transaction value constraint --- lib/operation.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/operation.ml') diff --git a/lib/operation.ml b/lib/operation.ml index bce6ac2..54962fd 100644 --- a/lib/operation.ml +++ b/lib/operation.ml @@ -47,7 +47,7 @@ let decoder : transaction_op Utils.Decoder.decoder = <|> literal "d" *> return (fun p -> `Debit p) in (fun value transaction_type description -> transaction_type { value; description }) - <$> ("valor" <: int) + <$> ("valor" <: (int >>= fun x -> if x >= 0 then return x else fail)) <*> ("tipo" <: transaction_type_decoder) <*> ("descricao" <: (string -- cgit v1.2.3