@@ -30,13 +30,13 @@ textConstraint :: DemotedTextConstraint -> State D4.Schema ()
30textConstraint (DTEq n) = modify $ \s -> s
30textConstraint (DTEq n) = modify $ \s -> s
31 { _schemaMinLength = pure $ fromIntegral n
31 { _schemaMinLength = pure $ fromIntegral n
32 , _schemaMaxLength = pure $ fromIntegral n }
32 , _schemaMaxLength = pure $ fromIntegral n }
33−textConstraint (DTLt n) = modify $ \s -> s
34− { _schemaMaxLength = pure . fromIntegral $ n + 1 }
35textConstraint (DTLe n) = modify $ \s -> s
33textConstraint (DTLe n) = modify $ \s -> s
36 { _schemaMaxLength = pure . fromIntegral $ n }
34 { _schemaMaxLength = pure . fromIntegral $ n }
37−textConstraint (DTGt n) =
35+textConstraint (DTLt n) =
38 let n' = if n == 0 then 0 else n - 1
36 let n' = if n == 0 then 0 else n - 1
37+ in modify $ \s -> s { _schemaMaxLength = pure . fromIntegral $ n' }
38+textConstraint (DTGt n) = modify $ \s -> s
39− in modify $ \s -> s { _schemaMinLength = pure . fromIntegral $ n' }
39+ { _schemaMinLength = pure . fromIntegral $ n + 1 }
40textConstraint (DTGe n) = modify $ \s -> s
40textConstraint (DTGe n) = modify $ \s -> s
41 { _schemaMinLength = pure . fromIntegral $ n }
41 { _schemaMinLength = pure . fromIntegral $ n }
42textConstraint (DTRegex r) = modify $ \s -> s { _schemaPattern = pure r }
42textConstraint (DTRegex r) = modify $ \s -> s { _schemaPattern = pure r }
@@ -48,18 +48,30 @@ numberConstraint :: DemotedNumberConstraint -> State D4.Schema ()
48numberConstraint (DNLe n) = modify $ \s -> s
48numberConstraint (DNLe n) = modify $ \s -> s
49 { _schemaMaximum = pure . fromIntegral $ n }
49 { _schemaMaximum = pure . fromIntegral $ n }
50numberConstraint (DNLt n) = modify $ \s -> s
50numberConstraint (DNLt n) = modify $ \s -> s
51− { _schemaMaximum = pure . fromIntegral $ n + 1 }
51+ { _schemaMaximum = pure . fromIntegral $ n
52+ , _schemaExclusiveMaximum = pure True }
52numberConstraint (DNGt n) = modify $ \s -> s
53numberConstraint (DNGt n) = modify $ \s -> s
54+ { _schemaMinimum = pure . fromIntegral $ n
55+ , _schemaExclusiveMinimum = pure True }
56+numberConstraint (DNGe n) = modify $ \s -> s
53 { _schemaMinimum = pure . fromIntegral $ n }
57 { _schemaMinimum = pure . fromIntegral $ n }
54−numberConstraint (DNGe n) =
55− let n' = if n == 0 then 0 else n - 1
56− in modify $ \s -> s { _schemaMinimum = pure . fromIntegral $ n' }
57numberConstraint (DNEq n) = modify $ \s -> s
58numberConstraint (DNEq n) = modify $ \s -> s
58 { _schemaMinimum = pure $ fromIntegral n
59 { _schemaMinimum = pure $ fromIntegral n
59 , _schemaMaximum = pure $ fromIntegral n }
60 , _schemaMaximum = pure $ fromIntegral n }
61arrayConstraint :: DemotedArrayConstraint -> State D4.Schema ()
62arrayConstraint :: DemotedArrayConstraint -> State D4.Schema ()
62−arrayConstraint (DAEq _) = pure ()
63+arrayConstraint (DALe n) = modify $ \s -> s
64+ { _schemaMaxItems = pure . fromIntegral $ n }
65+arrayConstraint (DALt n) =
66+ let n' = if n == 0 then 0 else n - 1
67+ in modify $ \s -> s { _schemaMaxItems = pure . fromIntegral $ n' }
68+arrayConstraint (DAGt n) = modify $ \s -> s
69+ { _schemaMinItems = pure . fromIntegral $ n + 1 }
70+arrayConstraint (DAGe n) = modify $ \s -> s
71+ { _schemaMinItems = pure . fromIntegral $ n }
72+arrayConstraint (DAEq n) = modify $ \s -> s
73+ { _schemaMinItems = pure $ fromIntegral n
74+ , _schemaMaxItems = pure $ fromIntegral n }
64toJsonSchema
76toJsonSchema
65 :: forall proxy schema
77 :: forall proxy schema