| Ed Tanous | 6df70ff | 2026-01-21 08:26:37 -0800 | [diff] [blame] | 1 | #ifndef __SCHEMAVALIDATOR_H |
| 2 | #define __SCHEMAVALIDATOR_H |
| 3 | |
| 4 | #include <json-c/json.h> |
| 5 | |
| 6 | int _schemavalidator_load(const char *jsonfile, const char *jsonschema); |
| 7 | int __schemavalidator_inspect_type(json_object *jobj, const char *type, |
| 8 | json_object *joutput_node); |
| 9 | int _schemavalidator_check_type(json_object *jobj, json_object *jschema, |
| 10 | json_object *joutput_node); |
| 11 | int _schemavalidator_check_required(json_object *jobj, json_object *jschema, |
| 12 | json_object *joutput_node); |
| 13 | int _schemavalidator_check_properties(json_object *jobj, json_object *jschema, |
| 14 | json_object *joutput_node); |
| 15 | int _schemavalidator_check_prefixItems_and_items(json_object *jobj, |
| 16 | json_object *jschema, |
| 17 | json_object *joutput_node); |
| 18 | int _schemavalidator_value_is_equal(json_object *jobj1, json_object *jobj2); |
| 19 | int _schemavalidator_check_const(json_object *jobj, json_object *jschema, |
| 20 | json_object *joutput_node); |
| 21 | int _schemavalidator_check_enums(json_object *jobj, json_object *jschema, |
| 22 | json_object *joutput_node); |
| 23 | int _schemavalidator_check_uniqueItems(json_object *jobj, json_object *jschema, |
| 24 | json_object *joutput_node); |
| 25 | int _schemavalidator_check_maxmin_items(json_object *jobj, json_object *jschema, |
| 26 | json_object *joutput_node); |
| 27 | int _schemavalidator_validate_array(json_object *jobj, json_object *jschema, |
| 28 | json_object *joutput_node); |
| 29 | int _schemavalidator_validate_object(json_object *jobj, json_object *jschema, |
| 30 | json_object *joutput_node); |
| 31 | int _schemavalidator_validate_string(json_object *jobj, json_object *jschema, |
| 32 | json_object *joutput_node); |
| 33 | int _schemavalidator_validate_integer(json_object *jobj, json_object *jschema, |
| 34 | json_object *joutput_node); |
| 35 | int _schemavalidator_validate_double(json_object *jobj, json_object *jschema, |
| 36 | json_object *joutput_node); |
| 37 | int _schemavalidator_validate_number(json_object *jobj, json_object *jschema, |
| 38 | double value, json_object *joutput_node); |
| 39 | int _schemavalidator_validate_boolean(json_object *jobj, json_object *jschema, |
| 40 | json_object *joutput_node); |
| 41 | int _schemavalidator_validate_instance(json_object *jobj, json_object *jschema, |
| 42 | json_object *joutput_node); |
| 43 | |
| 44 | json_object *_schemavalidator_output_create_node(const char *name); |
| 45 | void _schemavalidator_output_append_node(json_object *joutput, |
| 46 | json_object *jnode); |
| 47 | json_object * |
| 48 | _schemavalidator_output_create_and_append_node(json_object *joutput, |
| 49 | const char *name); |
| 50 | json_object *_schemavalidator_output_create_and_append_node_concatnames( |
| 51 | json_object *joutput, char *name1, char *name2); |
| 52 | |
| 53 | enum schemavalidator_errors { |
| 54 | SCHEMAVALIDATOR_ERR_VALID = 0, |
| 55 | SCHEMAVALIDATOR_ERR_GENERAL_ERROR, |
| 56 | SCHEMAVALIDATOR_ERR_JSON_NOT_FOUND, |
| 57 | SCHEMAVALIDATOR_ERR_SCHEMA_NOT_FOUND, |
| 58 | SCHEMAVALIDATOR_ERR_WRONG_ARGS, |
| 59 | SCHEMAVALIDATOR_ERR_SCHEMA_ERROR, |
| 60 | SCHEMAVALIDATOR_ERR_INVALID, |
| 61 | SCHEMAVALIDATOR_REGEX_MISMATCH, |
| 62 | SCHEMAVALIDATOR_REGEX_MATCH, |
| 63 | SCHEMAVALIDATOR_REGEX_COMPILE_FAILED, |
| 64 | SCHEMAVALIDATOR_ERR_MAX |
| 65 | }; |
| 66 | |
| 67 | void _schemavalidator_output_apply_result(json_object *joutput, |
| 68 | enum schemavalidator_errors err); |
| 69 | void _schemavalidator_output_print_errors(json_object *joutput); |
| 70 | |
| 71 | int schemavalidator_validate(json_object *jobj, json_object *jschema); |
| 72 | |
| 73 | const char *schemavalidator_errorstr(unsigned int schemavalidator_errors); |
| 74 | |
| 75 | #endif //__SCHEMAVALIDATOR_H |