File tree 2 files changed +12
-0
lines changed
src/commonMain/kotlin/io/github/optimumcode/json/schema
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,9 @@ public sealed class OutputCollector<T> private constructor(
93
93
94
94
internal abstract fun onError (error : ValidationError )
95
95
96
+ internal open val isFailFast: Boolean
97
+ get() = false
98
+
96
99
/* *
97
100
* A utility method that allows to call [reportErrors] method after the [block] has been executed
98
101
*/
@@ -117,6 +120,9 @@ public sealed class OutputCollector<T> private constructor(
117
120
override val output: Nothing
118
121
get() = throw UnsupportedOperationException (" no output in empty collector" )
119
122
123
+ override val isFailFast: Boolean
124
+ get() = true
125
+
120
126
override fun updateLocation (path : JsonPointer ): OutputCollector <Nothing > = this
121
127
122
128
override fun updateKeywordLocation (
@@ -193,6 +199,8 @@ public sealed class OutputCollector<T> private constructor(
193
199
) : OutputCollector<ValidationOutput.Flag>(parent, transformer) {
194
200
private var valid: Boolean = true
195
201
private var hasErrors: Boolean = false
202
+ override val isFailFast: Boolean
203
+ get() = true
196
204
override val output: ValidationOutput .Flag
197
205
get() =
198
206
if (valid) {
Original file line number Diff line number Diff line change @@ -24,9 +24,13 @@ internal class JsonSchemaRoot(
24
24
var result = true
25
25
context.pushSchemaPath(schemaPath, scopeId)
26
26
errorCollector.updateKeywordLocation(schemaPath).use {
27
+ val failFast = isFailFast
27
28
assertions.forEach {
28
29
val valid = it.validate(element, context, this )
29
30
result = result and valid
31
+ if (! result && failFast) {
32
+ return @use
33
+ }
30
34
}
31
35
}
32
36
context.popSchemaPath()
You can’t perform that action at this time.
0 commit comments