git.iko.soy/typeable/schematic
on master help sign in
Merge pull request #25 from ak3n/master
f5ed14aDenis Redozubov
src/Data/Schematic/JsonSchema.hs+5−4
@@ -47,11 +47,12 @@ 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) =
50+numberConstraint (DNLt n) = modify $ \s -> s
51− let n' = if n == 0 then 0 else n - 1
52− in modify $ \s -> s { _schemaMaximum = pure . fromIntegral $ n' }
51+ { _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 + 1 }
54+ { _schemaMinimum = pure . fromIntegral $ n
55+ , _schemaExclusiveMinimum = pure True }
55numberConstraint (DNGe n) = modify $ \s -> s
56numberConstraint (DNGe n) = modify $ \s -> s
56 { _schemaMinimum = pure . fromIntegral $ n }
57 { _schemaMinimum = pure . fromIntegral $ n }
57numberConstraint (DNEq n) = modify $ \s -> s
58numberConstraint (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" 2
79+ field @"n1" 1.1
80 :& field @"n2" 1
80 :& field @"n2" 1
81− :& field @"n3" 0
81+ :& field @"n3" 0.9
82− :& field @"n4" 1
82+ :& field @"n4" 1.0
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"