bootstrap/include/validator.h

31 lines
640 B
C
Raw Normal View History

2023-11-24 17:27:44 +00:00
#ifndef _BOOTSTRAP_VALIDATOR_H
#define _BOOTSTRAP_VALIDATOR_H
#include "cJSON.h"
#include "dyn_array.h"
enum FieldType {
FT_STRING = 1,
2023-11-24 17:27:44 +00:00
};
struct Field {
enum FieldType type;
2023-11-24 17:27:44 +00:00
const char *key;
const char *prompt;
2023-11-24 17:27:44 +00:00
};
enum SpecValidationError {
// 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
validate_spec_json(const cJSON *const parsed, struct DynArray **fields);
2023-11-24 17:27:44 +00:00
#endif /* _BOOTSTRAP_VALIDATOR_H */