@@ -28,7 +28,7 @@ import Prelude.Compat
2828
2929import Control.Applicative
3030import Control.Lens hiding (allOf )
31- import Control.Monad (forM , forM_ , when )
31+ import Control.Monad (forM , when )
3232
3333import Data.Aeson hiding (Result )
3434import Data.Foldable (for_ , sequenceA_ ,
@@ -44,6 +44,7 @@ import Data.Text (Text)
4444import qualified Data.Text as Text
4545import qualified Data.Text.Lazy as TL
4646import qualified Data.Text.Lazy.Encoding as TL
47+ import Data.Traversable (for )
4748import Data.Vector (Vector )
4849import qualified Data.Vector as Vector
4950
@@ -476,10 +477,11 @@ validateSchemaType val = withSchema $ \sch ->
476477 1 -> valid
477478 _ -> invalid $ " Value matches more than one of 'oneOf' schemas: " ++ show val
478479 (view allOf -> Just variants) -> do
479- -- Default semantics for Validation Monad will abort when at least one
480- -- variant does not match.
481- forM_ variants $ \ var ->
482- validateWithSchemaRef var val
480+ schemas <- for variants $ \ case
481+ Ref ref -> withRef ref pure
482+ Inline s -> pure s
483+
484+ sub (mconcat schemas) $ validateWithSchema val
483485
484486 _ ->
485487 case (sch ^. type_, val) of
0 commit comments