@@ -8,27 +8,28 @@ const string = @import("string.zig");
88const array = @import ("array.zig" );
99const json_pointer = @import ("json_pointer.zig" );
1010const boolean_logic = @import ("boolean_logic.zig" );
11+ const conditional = @import ("conditional.zig" );
1112
1213pub const ErrorSet = std .mem .Allocator .Error || std .fmt .ParseIntError || json_pointer .Error ;
1314
1415pub fn checksFromObject (schema : std.json.ObjectMap , data : std.json.Value , stack : * Stack , collect_errors : ? * Errors ) ErrorSet ! bool {
15- var valid = try generic .checks (schema , data , stack , collect_errors );
16- if (! valid and collect_errors == null ) return false ;
16+ if (! try generic .checks (schema , data , stack , collect_errors ) and collect_errors == null ) return false ;
1717
18- valid = switch (data ) {
18+ if ( ! switch (data ) {
1919 .integer = > | i | try numeric .checks (i64 , schema , i , stack , collect_errors ),
2020 .float = > | f | try numeric .checks (f64 , schema , f , stack , collect_errors ),
2121 .number_string = > unreachable ,
2222 .string = > | str | try string .checks (schema , str , stack , collect_errors ),
2323 .object = > try object .checks (schema , data , stack , collect_errors ),
2424 .array = > try array .checks (schema , data , stack , collect_errors ),
2525 else = > true ,
26- } and valid ;
27- if (! valid and collect_errors == null ) return false ;
26+ } and collect_errors == null ) return false ;
2827
29- valid = try boolean_logic .checks (schema , data , stack , collect_errors ) and valid ;
28+ if ( ! try conditional .checks (schema , data , stack , collect_errors ) and collect_errors == null ) return false ;
3029
31- return valid ;
30+ if (! try boolean_logic .checks (schema , data , stack , collect_errors ) and collect_errors == null ) return false ;
31+
32+ return if (collect_errors ) | errors | errors .empty () else true ;
3233}
3334
3435pub fn checks (schema : std.json.Value , data : std.json.Value , stack : * Stack , collect_errors : ? * Errors ) ErrorSet ! bool {
0 commit comments