23 default:
return "unknown";
41 default:
return false;
70 if (!json || !schema) {
71 add_error(&r,
"(root)",
"null json or schema pointer");
76 add_error(&r,
"(root)",
"expected a JSON object at root");
117 if (out) *out =
NULL;
120 add_error(&r,
"(root)",
"null input string");
126 add_error(&r,
"(root)",
"JSON parse error: invalid syntax");
cwist_field_type_t
Expected value type for a schema field.
Single field descriptor used by both the healer and the Zod validator.
bool required
Must be present?
const char * name
Canonical field name.
cwist_field_type_t type
Expected value type.
A complete schema: array of field descriptors + count.
const cwist_schema_field_t * fields
A single validation failure.
char message[CWIST_ZOD_MSG_MAX]
char field[CWIST_ZOD_FIELD_MAX]
Result returned by cwist_zod_validate() / cwist_zod_parse().
cwist_zod_error_t errors[CWIST_ZOD_MAX_ERRORS]
cwist_zod_result_t cwist_zod_validate(const cJSON *json, const cwist_schema_t *schema)
Validate a parsed JSON object against a flat CWIST schema.
void cwist_zod_print_errors(const cwist_zod_result_t *r)
Print validation errors to stderr using the built-in ZOD-like format.
cwist_zod_result_t cwist_zod_parse(const char *raw, const cwist_schema_t *schema, cJSON **out)
Parse raw JSON text and validate it against a CWIST schema.
Strict JSON schema validation (Zod-style) for CWIST.
#define CWIST_ZOD_FIELD_MAX
#define CWIST_ZOD_MSG_MAX
#define CWIST_ZOD_MAX_ERRORS