on 280ea5d help sign in
src/Data/Schematic/JsonSchema.hs+4−5
since splitsnapshots
unifiedsplit
@@ -47,12 +47,11 @@ textConstraint (DTEnum ss) =
47numberConstraint :: DemotedNumberConstraint -> State D4.Schema ()
47numberConstraint :: 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 }
50−numberConstraint (DNLt n) = modify $ \s -> s
50+numberConstraint (DNLt n) =
51+ let n' = if n == 0 then 0 else n - 1
51− { _schemaMaximum = pure . fromIntegral $ n
52+ in modify $ \s -> s { _schemaMaximum = pure . fromIntegral $ n' }
52− , _schemaExclusiveMaximum = pure True }
53numberConstraint (DNGt n) = modify $ \s -> s
53numberConstraint (DNGt n) = modify $ \s -> s
54− { _schemaMinimum = pure . fromIntegral $ n
54+ { _schemaMinimum = pure . fromIntegral $ n + 1 }
55− , _schemaExclusiveMinimum = pure True }
56numberConstraint (DNGe n) = modify $ \s -> s
55numberConstraint (DNGe n) = modify $ \s -> s
57 { _schemaMinimum = pure . fromIntegral $ n }
56 { _schemaMinimum = pure . fromIntegral $ n }
58numberConstraint (DNEq n) = modify $ \s -> s
57numberConstraint (DNEq n) = modify $ \s -> s
test/JsonSchemaSpec.hs+3−3
@@ -76,10 +76,10 @@ spec = do
76 let
76 let
77 schema = D4.SchemaWithURI (fromJust $ toJsonSchema (Proxy @SchemaNumberExample)) Nothing
77 schema = D4.SchemaWithURI (fromJust $ toJsonSchema (Proxy @SchemaNumberExample)) Nothing
78 obj = withRepr @SchemaNumberExample $
78 obj = withRepr @SchemaNumberExample $
79− field @"n1" 1.1
79+ field @"n1" 2
80 :& field @"n2" 1
80 :& field @"n2" 1
81− :& field @"n3" 0.9
81+ :& field @"n3" 0
82− :& field @"n4" 1.0
82+ :& field @"n4" 1
83 :& RNil
83 :& RNil
84 fetchHTTPAndValidate schema (toJSON obj) >>= \case
84 fetchHTTPAndValidate schema (toJSON obj) >>= \case
85 Left e -> fail "failed to validate test example"
85 Left e -> fail "failed to validate test example"