2023-11-24 17:27:44 +00:00
|
|
|
#ifndef _BOOTSTRAP_VALIDATOR_H
|
|
|
|
#define _BOOTSTRAP_VALIDATOR_H
|
|
|
|
|
|
|
|
#include "cJSON.h"
|
|
|
|
#include "dyn_array.h"
|
|
|
|
|
2023-11-25 02:29:14 +00:00
|
|
|
enum FieldType {
|
|
|
|
FT_STRING = 1,
|
2023-11-24 17:27:44 +00:00
|
|
|
};
|
|
|
|
|
2023-11-25 02:29:14 +00:00
|
|
|
struct Field {
|
|
|
|
enum FieldType type;
|
2023-11-24 17:27:44 +00:00
|
|
|
const char *key;
|
2023-11-25 02:29:14 +00:00
|
|
|
const char *prompt;
|
2023-11-24 17:27:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum SpecValidationError {
|
2023-11-25 02:29:14 +00:00
|
|
|
// The top-level JSON value of a `spec.json` file must be a JSON object.
|
|
|
|
SVE_TOPLEVEL_NOT_OBJECT = 1,
|
|
|
|
// The field is not a JSON object.
|
|
|
|
SVE_FIELD_NOT_OBJECT,
|
|
|
|
SVE_FIELD_TYPE_INVALID,
|
|
|
|
SVE_FIELD_TYPE_UNKNOWN,
|
|
|
|
SVE_FIELD_PROMPT_INVALID,
|
2023-11-24 17:27:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum SpecValidationError
|
2023-11-25 02:29:14 +00:00
|
|
|
validate_spec_json(const cJSON *const parsed, struct DynArray **fields);
|
2023-11-24 17:27:44 +00:00
|
|
|
|
|
|
|
#endif /* _BOOTSTRAP_VALIDATOR_H */
|