2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 2013, Digium, Inc.
6 * See http://www.asterisk.org for more information about
7 * the Asterisk project. Please do not directly contact
8 * any of the maintainers of this project for assistance;
9 * the project provides a web site, mailing lists and IRC
10 * channels for your use.
12 * This program is free software, distributed under the terms of
13 * the GNU General Public License Version 2. See the LICENSE file
14 * at the top of the source tree.
19 * \brief Generated file - Build validators for ARI model objects.
24 * This file is generated by a mustache template. Please see the original
25 * template in rest-api-templates/ari_model_validators.c.mustache
30 ASTERISK_REGISTER_FILE()
32 #include "asterisk/logger.h"
33 #include "asterisk/module.h"
34 #include "ari_model_validators.h"
39 int ast_ari_validate_{{c_id}}(struct ast_json *json)
42 struct ast_json_iter *iter;
49 const char *discriminator;
51 discriminator = ast_json_string_get(ast_json_object_get(json, "{{discriminator.name}}"));
53 ast_log(LOG_ERROR, "ARI {{id}} missing required field {{discriminator.name}}\n");
57 if (strcmp("{{id}}", discriminator) == 0) {
58 /* Self type; fall through */
61 if (strcmp("{{id}}", discriminator) == 0) {
62 return ast_ari_validate_{{c_id}}(json);
66 ast_log(LOG_ERROR, "ARI {{id}} has undocumented subtype %s\n",
72 for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
74 if (strcmp("{{name}}", ast_json_object_iter_key(iter)) == 0) {
81 prop_is_valid = ast_ari_validate_list(
82 ast_json_object_iter_value(iter),
83 ast_ari_validate_{{c_singular_name}});
86 prop_is_valid = ast_ari_validate_{{c_name}}(
87 ast_json_object_iter_value(iter));
91 ast_log(LOG_ERROR, "ARI {{id}} field {{name}} failed validation\n");
98 "ARI {{id}} has undocumented field %s\n",
99 ast_json_object_iter_key(iter));
107 ast_log(LOG_ERROR, "ARI {{id}} missing required field {{name}}\n");
116 ari_validator ast_ari_validate_{{c_id}}_fn(void)
118 return ast_ari_validate_{{c_id}};