@@ -11,7 +11,7 @@ class Context {
11
11
self . validator = validator
12
12
}
13
13
14
- func validate( instance: Any , schema: Any ) -> AnySequence < ValidationError > {
14
+ func validate( instance: Any , schema: Any ) throws -> AnySequence < ValidationError > {
15
15
if let schema = schema as? Bool {
16
16
if schema == true {
17
17
return AnySequence ( EmptyCollection ( ) )
@@ -30,13 +30,13 @@ class Context {
30
30
// Older versions of JSON Schema, $ref ignores any alongside keywords
31
31
if let ref = schema [ " $ref " ] as? String {
32
32
let validation = validator. validations [ " $ref " ] !
33
- return validation ( self , ref, instance, schema)
33
+ return try validation ( self , ref, instance, schema)
34
34
}
35
35
}
36
36
37
- return AnySequence ( validator. validations. compactMap { ( key, validation) -> AnySequence < ValidationError > in
37
+ return try AnySequence ( validator. validations. compactMap { ( key, validation) -> AnySequence < ValidationError > in
38
38
if let value = schema [ key] {
39
- return validation ( self , value, instance, schema)
39
+ return try validation ( self , value, instance, schema)
40
40
}
41
41
42
42
return AnySequence ( EmptyCollection ( ) )
@@ -47,13 +47,13 @@ class Context {
47
47
return resolver. resolve ( reference: ref)
48
48
}
49
49
50
- func descend( instance: Any , subschema: Any ) -> AnySequence < ValidationError > {
51
- return validate ( instance: instance, schema: subschema)
50
+ func descend( instance: Any , subschema: Any ) throws -> AnySequence < ValidationError > {
51
+ return try validate ( instance: instance, schema: subschema)
52
52
}
53
53
}
54
54
55
55
protocol Validator {
56
- typealias Validation = ( Context , Any , Any , [ String : Any ] ) -> AnySequence < ValidationError >
56
+ typealias Validation = ( Context , Any , Any , [ String : Any ] ) throws -> AnySequence < ValidationError >
57
57
58
58
var resolver : RefResolver { get }
59
59
@@ -66,11 +66,11 @@ protocol Validator {
66
66
extension Validator {
67
67
public func validate( instance: Any ) throws -> ValidationResult {
68
68
let context = Context ( resolver: resolver, validator: self )
69
- return context. validate ( instance: instance, schema: schema) . validationResult ( )
69
+ return try context. validate ( instance: instance, schema: schema) . validationResult ( )
70
70
}
71
71
72
72
public func validate( instance: Any ) throws -> AnySequence < ValidationError > {
73
73
let context = Context ( resolver: resolver, validator: self )
74
- return context. validate ( instance: instance, schema: schema)
74
+ return try context. validate ( instance: instance, schema: schema)
75
75
}
76
76
}
0 commit comments