Skip to content

Commit

Permalink
chore: fix remaining failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
n1k0 committed Feb 27, 2025
1 parent 32f26d3 commit 3ae6244
Show file tree
Hide file tree
Showing 5 changed files with 224 additions and 250 deletions.
29 changes: 19 additions & 10 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -814,17 +814,26 @@ components:
minimum: 1
maximum: 1000
printing:
type: string
type: object
description: |
Ce paramètre permet de préciser le type d'impression effectuée sur le produit, suivi du pourcentage de
surface teinte. Par exemple, `pigment;0.1` signifie impression pigmentaire sur 10% de la superficie du
vêtement. L'identifiant de procédé d'impression peut prendre les valeurs suivantes :
- `pigment` pour une impression pigmentaire ;
- `substantive` pour une impression fixé/lavé ;
enum:
- pigment
- substantive
Ce paramètre permet de préciser le type d'impression effectuée sur le produit.
Par exemple, `{"kind": "pigment", "ratio": 0.1}` signifie impression pigmentaire sur 10%
de la superficie du vêtement.
required: ["kind"]
properties:
kind:
type: string
description: |
Type de procédé d'impression pouvant prendre les valeurs suivantes :
- `pigment` pour une impression pigmentaire ;
- `substantive` pour une impression fixé/lavé ;
enum:
- pigment
- substantive
ratio:
type: number
description: |
Pourcentage de surface teinte, exprimé entre `0` et `1`
product:
type: string
description: |
Expand Down
7 changes: 4 additions & 3 deletions src/Data/Textile/Printing.elm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module Data.Textile.Printing exposing
import Data.Split as Split exposing (Split)
import Json.Decode as Decode exposing (Decoder)
import Json.Decode.Extra as DE
import Json.Decode.Pipeline as JDP
import Json.Encode as Encode


Expand All @@ -29,9 +30,9 @@ type alias Printing =

decode : Decoder Printing
decode =
Decode.map2 Printing
(Decode.field "kind" decodeKind)
(Decode.field "ratio" Split.decodeFloat)
Decode.succeed Printing
|> JDP.required "kind" decodeKind
|> JDP.optional "ratio" Split.decodeFloat defaultRatio


decodeKind : Decoder Kind
Expand Down
6 changes: 3 additions & 3 deletions src/Data/Textile/Validation.elm
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import Result.Extra as RE
import Static.Db exposing (Db)


{-| Validate a Textile Query.
Note: many fields are inherently validated by their types and/or at decoding time.
{-| Validate values not fully qualified by their type or applied JSON decoders.
-}
validate : Db -> Query -> Result String Query
validate db query =
Expand All @@ -36,6 +35,7 @@ validate db query =
|> RE.andMap (query.makingDeadStock |> validateMaybe validateMakingDeadStock)
|> RE.andMap (query.makingWaste |> validateMaybe validateMakingWaste)
|> RE.andMap (validateMass query.mass)
-- FIXME: validate nonempty materials list here
|> RE.andMap (Ok query.materials)
|> RE.andMap (Ok query.numberOfReferences)
|> RE.andMap (Ok query.physicalDurability)
Expand Down Expand Up @@ -73,7 +73,7 @@ validateMakingDeadStock =
validateMakingWaste : Split -> Result String Split
validateMakingWaste =
validateSplitWithin "Le taux de perte en confection"
{ max = Env.minMakingWasteRatio, min = Env.minMakingWasteRatio }
{ max = Env.maxMakingWasteRatio, min = Env.minMakingWasteRatio }


validateMass : Mass -> Result String Mass
Expand Down
Loading

0 comments on commit 3ae6244

Please sign in to comment.