29 #include "Requirement.h"
77 virtual void Parse(Value json,
const std::string& path)
override
82 if(json.isMember(
"multipleOf") && json[
"multipleOf"].isNumeric())
88 if(json.isMember(
"minimum") && json[
"minimum"].isNumeric())
91 min_ = json[
"minimum"].asDouble();
94 if(json.isMember(
"maximum") && json[
"maximum"].isNumeric())
97 max_ = json[
"maximum"].asDouble();
100 if(json.isMember(
"exclusiveMinimum") && json[
"exclusiveMinimum"].isBool())
102 exclMin_ = json[
"exclusiveMinimum"].asBool();
105 if(json.isMember(
"exclusiveMaximum") && json[
"exclusiveMaximum"].isBool())
107 exclMax_ = json[
"exclusiveMaximum"].asBool();
120 virtual void Validate(
const Value& json,
const std::string& path)
override
122 if(!json.isNumeric())
124 PushError(path +
": Must be of type \"number\".");
134 PushError(path +
": Value must be greater than " + std::to_string(
min_));
135 else if(json.asDouble() <
min_)
136 PushError(path +
": Value cannot be less than " + std::to_string(
min_));
142 PushError(path +
": Value must be less than " + std::to_string(
max_));
143 else if(json.asDouble() >
max_)
144 PushError(path +
": Value cannot be greater than " + std::to_string(
max_));
Requirements on a numeric value.
virtual void Parse(Value json, const std::string &path) override
Parse JSON value to set up Requirement.
double max_
Upper bound for range requirement.
virtual void Validate(const Value &json, const std::string &path) override
Validate JSON value.
bool exclMax_
If True, upper bound is exclusive.
bool exclMin_
If True, lower bound is exclusive.
double min_
Lower bound for range requirement.
bool multSet_
If True, "Multiple of" requirement is active.
NumberRequirement()
Constructor.
bool maxSet_
If True, Upper bound for range requirement is active.
bool minSet_
If True, Lower bound for range requirement is active.
double multipleOf_
Base value for "multiple of" requirement.
virtual void Reset() override
Reset Requirement.
std::string path_
JSON path.
Requirements on input files.
virtual void ClearNotices()
Clear list of notice messages.
virtual void ClearErrors()
Clear list of error messages.
void PushError(const std::string &error)
Add error to list of error messages.