@@ -1,5 +1,3 @@
1−{-# LANGUAGE OverloadedLists #-}
2−
31-- | This is generally meant to be an internal module.
42-- It's only exposed in case you want to make your own
53-- 'Spec'. If you just want to use JSON Schema Draft 4
@@ -66,7 +64,7 @@ objEmbed _ _ = V.empty
6664
6765-- TODO: optimize
6866arrayEmbed :: Text -> Value -> Vector RawSchema
69−arrayEmbed t (Array vs) = V.concat . V.toList $ (\o -> objEmbed t o) <$> vs
67+arrayEmbed t (Array vs) = V.concat . V.toList $ objEmbed t <$> vs
7068arrayEmbed _ _ = V.empty
7169
7270objOrArrayEmbed :: Text -> Value -> Vector RawSchema
@@ -75,7 +73,7 @@ objOrArrayEmbed t v@(Array _) = arrayEmbed t v
7573objOrArrayEmbed _ _ = V.empty
7674
7775objMembersEmbed :: Text -> Value -> Vector RawSchema
78−objMembersEmbed t (Object o) = V.concat $ (\x -> objEmbed t x) <$> H.elems o
76+objMembersEmbed t (Object o) = V.concat $ objEmbed t <$> H.elems o
7977objMembersEmbed _ _ = V.empty
8078
8179--------------------------------------------------
@@ -190,7 +188,7 @@ additionalItems' _ _ _ (Bool val) =
190188 Just (\x ->
191189 case x of
192190 (Array ys) -> if not val && V.length ys > 0
193− then V.singleton "TODO"
191+ then V.singleton ("Val error against additionalItems false for: " <> tshow x)
194192 else mempty
195193 _ -> mempty)
196194additionalItems' spec g s (Object val) =
@@ -230,7 +228,8 @@ uniqueItems _ _ _ (Bool val) = do
230228 case x of
231229 (Array ys) -> if allUnique ys
232230 then mempty
233− else V.singleton "TODO"
231+ else V.singleton
232+ ("Val error against uniqueItems " <> tshow val <> " for: " <> tshow x)
234233 _ -> mempty)
235234uniqueItems _ _ _ _ = Nothing
236235
@@ -374,9 +373,9 @@ additionalProperties' :: ValidatorGen
374373additionalProperties' _ _ _ (Bool val) =
375374 Just (\x ->
376375 case x of
377− (Object y) -> if val || H.size y == 0
378− then mempty
379− else V.singleton "TODO"
376+ (Object y) -> if not val && H.size y > 0
377+ then V.singleton ("Val error against additionalProperties false for: " <> tshow x)
378+ else mempty
380379 _ -> mempty)
381380additionalProperties' spec g s (Object val) =
382381 let sub = compile spec g (RawSchema (_rsURI s) val)
@@ -444,7 +443,9 @@ dependencies spec g s (Object val) = do
444443 Nothing -> mempty
445444 Just _ ->
446445 case traverse ($ d) (H.lookup <$> ts) of
447− Nothing -> V.singleton "TODO at least one failed"
446+ Nothing -> V.singleton
447+ ("Val error against property dependency with the key "
448+ <> t <> " and the value " <> tshow ts <> " for: " <> tshow d)
448449 Just _ -> mempty
449450
450451dependencies _ _ _ _ = Nothing
@@ -484,7 +485,7 @@ anyOf spec g s (Array vs) = do
484485 Just (\x ->
485486 if V.elem V.empty (validate <$> ss <*> pure x)
486487 then mempty
487− else V.singleton "TODO")
488+ else V.singleton ("Val error against anyOf " <> tshow vs <> " for: " <> tshow x))
488489anyOf _ _ _ _ = Nothing
489490
490491oneOf :: ValidatorGen
@@ -494,7 +495,7 @@ oneOf spec g s (Array vs) = do
494495 Just (\x ->
495496 if count V.empty (validate <$> ss <*> pure x) == 1
496497 then mempty
497− else V.singleton "TODO")
498+ else V.singleton ("Val error against oneOf " <> tshow vs <> " for: " <> tshow x))
498499oneOf _ _ _ _ = Nothing
499500
500501notValidator :: ValidatorGen
@@ -502,7 +503,7 @@ notValidator spec g s (Object val) = do
502503 let sub = compile spec g (RawSchema (_rsURI s) val)
503504 Just (\x ->
504505 if V.null $ validate sub x
505− then V.singleton "TODO"
506+ then V.singleton ("Val error against not validator " <> tshow val <> " for: " <> tshow x)
506507 else mempty)
507508notValidator _ _ _ _ = Nothing
508509
@@ -526,4 +527,4 @@ ref spec g s (String val) = do
526527ref _ _ _ _ = Nothing
527528
528529noVal :: ValidatorGen
529−noVal = (\_ _ _ _ -> Just (const V.empty))
530+noVal _ _ _ _ = Just (const V.empty)