@@ -70,29 +70,16 @@ embedded schema = concat
7070 checkDependency (OB.PropertyDependency _) = Nothing
7171 checkDependency (OB.SchemaDependency s) = Just s
7272
73−--------------------------------------------------
74−-- * Validation (Exported from 'Data.JsonSchema.Draft4')
75−--------------------------------------------------
76−
77−-- | In normal situations just use 'checkSchema', which is a combination of
78−-- 'schemaValidity' and 'runValidate'.
79−runValidate
80− :: ReferencedSchemas Schema
81− -> SchemaWithURI Schema
82− -> Value
83− -> [Failure]
84−runValidate = (fmap.fmap.fmap.fmap) specializeForDraft4 validateAny
85−
8673--------------------------------------------------
8774-- * Validation (Main internal functions)
8875--------------------------------------------------
8976
90−validateAny
77+runValidate
9178 :: ReferencedSchemas Schema
9279 -> SchemaWithURI Schema
9380 -> Value
94− -> [FR.Failure ValidatorChain]
95−validateAny referenced sw x = concat
81+ -> [Invalid]
82+runValidate referenced sw x = concat
9683 [ f _schemaEnum (setFailure Enum) (fmap maybeToList . AN.enumVal)
9784 , f _schemaType (setFailure TypeValidator) (fmap maybeToList . AN.typeVal)
9885 , f _schemaAllOf (modFailure AllOf) (AN.allOf recurse)
@@ -102,7 +89,7 @@ validateAny referenced sw x = concat
10289 , refFailures
10390 ] <> specificValidators
10491 where
105− specificValidators :: [FR.Failure ValidatorChain]
92+ specificValidators :: [Invalid]
10693 specificValidators =
10794 case x of
10895 Number y -> validateNumber (_swSchema sw) y
@@ -120,16 +107,16 @@ validateAny referenced sw x = concat
120107 --
121108 -- [1] A list of errors wrapped in a 'Maybe' where 'Nothing' represents
122109 -- if resolving the reference itself failed.
123− refFailures :: [FR.Failure ValidatorChain]
110+ refFailures :: [Invalid]
124111 refFailures =
125112 case _schemaRef (_swSchema sw) of
126113 Nothing -> mempty
127114 Just reference ->
128− maybe [FR.Failure RefResolution (toJSON reference) mempty]
115+ maybe [FR.Invalid RefResolution (toJSON reference) mempty]
129116 (fmap (modFailure Ref))
130117 $ AN.ref scope
131118 getReference
132− (\a b -> validateAny referenced (SchemaWithURI b a))
119+ (\a b -> runValidate referenced (SchemaWithURI b a))
133120 reference
134121 x
135122 where
@@ -143,7 +130,7 @@ validateAny referenced sw x = concat
143130validateString
144131 :: Schema
145132 -> Text
146− -> [FR.Failure ValidatorChain]
133+ -> [Invalid]
147134validateString schema x = concat
148135 [ f _schemaMaxLength (setFailure MaxLength) (fmap maybeToList . ST.maxLength)
149136 , f _schemaMinLength (setFailure MinLength) (fmap maybeToList . ST.minLength)
@@ -155,7 +142,7 @@ validateString schema x = concat
155142validateNumber
156143 :: Schema
157144 -> Scientific
158− -> [FR.Failure ValidatorChain]
145+ -> [Invalid]
159146validateNumber schema x = concat
160147 [ f _schemaMultipleOf (setFailure MultipleOf) (fmap maybeToList . NU.multipleOf)
161148 , f _schemaMaximum
@@ -182,7 +169,7 @@ validateArray
182169 :: ReferencedSchemas Schema
183170 -> SchemaWithURI Schema
184171 -> Vector Value
185− -> [FR.Failure ValidatorChain]
172+ -> [Invalid]
186173validateArray referenced (SchemaWithURI schema mUri) x = concat
187174 [ f _schemaMaxItems (setFailure MaxItems) (fmap maybeToList . AR.maxItems)
188175 , f _schemaMinItems (setFailure MinItems) (fmap maybeToList . AR.minItems)
@@ -204,7 +191,7 @@ validateObject
204191 :: ReferencedSchemas Schema
205192 -> SchemaWithURI Schema
206193 -> HashMap Text Value
207− -> [FR.Failure ValidatorChain]
194+ -> [Invalid]
208195validateObject referenced (SchemaWithURI schema mUri) x = concat
209196 [ f _schemaMaxProperties (setFailure MaxProperties) (fmap maybeToList . OB.maxProperties)
210197 , f _schemaMinProperties (setFailure MinProperties) (fmap maybeToList . OB.minProperties)
@@ -262,9 +249,9 @@ descendNextLevel
262249 -> SchemaWithURI Schema
263250 -> Schema
264251 -> Value
265− -> [FR.Failure ValidatorChain]
252+ -> [Invalid]
266253descendNextLevel referenced (SchemaWithURI schema mUri) =
267− validateAny referenced . flip SchemaWithURI scope
254+ runValidate referenced . flip SchemaWithURI scope
268255 where
269256 scope :: Maybe Text
270257 scope = updateResolutionScope mUri (_schemaId schema)
@@ -273,8 +260,8 @@ runSingle
273260 :: Schema
274261 -> dta
275262 -> (Schema -> Maybe val)
276− -> (err -> FR.Failure ValidatorChain)
263+ -> (err -> Invalid)
277264 -> (val -> dta -> [err])
278− -> [FR.Failure ValidatorChain]
265+ -> [Invalid]
279266runSingle schema dta field modifyError validate =
280267 maybe mempty (\val -> modifyError <$> validate val dta) (field schema)