@@ -29,7 +29,7 @@ import Prelude.Compat
2929
3030import Control.Applicative
3131import Control.Lens hiding (allOf )
32- import Control.Monad (forM , forM_ , when )
32+ import Control.Monad (forM , when )
3333
3434import Data.Aeson hiding (Result )
3535#if MIN_VERSION_aeson(2,0,0)
@@ -49,6 +49,7 @@ import Data.Text (Text)
4949import qualified Data.Text as Text
5050import qualified Data.Text.Lazy as TL
5151import qualified Data.Text.Lazy.Encoding as TL
52+ import Data.Traversable (for )
5253import Data.Vector (Vector )
5354import qualified Data.Vector as Vector
5455
@@ -488,10 +489,11 @@ validateSchemaType val = withSchema $ \sch ->
488489 1 -> valid
489490 _ -> invalid $ " Value matches more than one of 'oneOf' schemas: " ++ show val
490491 (view allOf -> Just variants) -> do
491- -- Default semantics for Validation Monad will abort when at least one
492- -- variant does not match.
493- forM_ variants $ \ var ->
494- validateWithSchemaRef var val
492+ schemas <- for variants $ \ case
493+ Ref ref -> withRef ref pure
494+ Inline s -> pure s
495+
496+ sub (mconcat schemas) $ validateWithSchema val
495497
496498 _ ->
497499 case (sch ^. type_, val) of
0 commit comments