|
cwist
Modern C web framework with libttak runtime
|
Lightweight schema validation helpers for cJSON payloads. More...

Go to the source code of this file.
Functions | |
| 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. | |
| 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. | |
| void | cwist_zod_print_errors (const cwist_zod_result_t *r) |
| Print validation errors to stderr using the built-in ZOD-like format. | |
Lightweight schema validation helpers for cJSON payloads.
Definition in file zod.c.
| 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.
Parse a raw JSON string and validate it in one step.
| raw | Raw JSON text to parse. |
| schema | Expected field list and type requirements. |
| out | Optional output pointer that receives the parsed cJSON object on success. |
Definition at line 112 of file zod.c.
References cap, cwist_zod_validate(), and cwist_zod_result::valid.
Referenced by cwist_db_insert_healed().
| void cwist_zod_print_errors | ( | const cwist_zod_result_t * | r | ) |
Print validation errors to stderr using the built-in ZOD-like format.
Print all validation errors to stderr.
| r | Validation result to print. |
Definition at line 146 of file zod.c.
References cap, cwist_zod_result::error_count, cwist_zod_result::errors, cwist_zod_error::field, and cwist_zod_error::message.
Referenced by cwist_db_insert_healed().
| 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.
Strictly validate an already-parsed cJSON object against a schema.
| json | Parsed JSON object to inspect. |
| schema | Expected field list and type requirements. |
Definition at line 65 of file zod.c.
References cap, CWIST_ZOD_MSG_MAX, cwist_schema::field_count, cwist_schema::fields, cwist_schema_field::name, cwist_schema_field::required, cwist_schema_field::type, and cwist_zod_result::valid.
Referenced by cwist_db_query_strict(), and cwist_zod_parse().