summaryrefslogtreecommitdiffstats
path: root/Source/cmCMakePresetsGraphReadJSON.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmCMakePresetsGraphReadJSON.cxx')
-rw-r--r--Source/cmCMakePresetsGraphReadJSON.cxx12
1 files changed, 6 insertions, 6 deletions
diff --git a/Source/cmCMakePresetsGraphReadJSON.cxx b/Source/cmCMakePresetsGraphReadJSON.cxx
index df6482d..18ae9af 100644
--- a/Source/cmCMakePresetsGraphReadJSON.cxx
+++ b/Source/cmCMakePresetsGraphReadJSON.cxx
@@ -256,9 +256,14 @@ auto const VersionIntHelper =
auto const VersionHelper = JSONHelperBuilder::Required<int>(
cmCMakePresetsErrors::NO_VERSION, VersionIntHelper);
+auto const VersionRangeHelper = JSONHelperBuilder::Checked<int>(
+ cmCMakePresetsErrors::UNRECOGNIZED_VERSION_RANGE(MIN_VERSION, MAX_VERSION),
+ VersionHelper,
+ [](const int v) -> bool { return v >= MIN_VERSION && v <= MAX_VERSION; });
+
auto const RootVersionHelper =
JSONHelperBuilder::Object<int>(cmCMakePresetsErrors::INVALID_ROOT_OBJECT)
- .Bind("version"_s, VersionHelper, false);
+ .Bind("version"_s, VersionRangeHelper, false);
auto const CMakeVersionUIntHelper =
JSONHelperBuilder::UInt(cmCMakePresetsErrors::INVALID_VERSION);
@@ -481,11 +486,6 @@ bool cmCMakePresetsGraph::ReadJSONFile(const std::string& filename,
if ((result = RootVersionHelper(v, &root, &parseState)) != true) {
return result;
}
- if (v < MIN_VERSION || v > MAX_VERSION) {
- cmCMakePresetsErrors::UNRECOGNIZED_VERSION(&root["version"],
- &this->parseState);
- return false;
- }
// Support for build and test presets added in version 2.
if (v < 2) {