✅ test read only values
This commit is contained in:
parent
f472bcca1e
commit
3d7feb1125
@ -73,3 +73,7 @@ add_test(NAME issue-149-entry-selection COMMAND issue-149-entry-selection)
|
||||
add_executable(issue-189-default-values issue-189-default-values.cpp)
|
||||
target_link_libraries(issue-189-default-values nlohmann_json_schema_validator)
|
||||
add_test(NAME issue-189-default-values COMMAND issue-189-default-values)
|
||||
|
||||
add_executable(issue-212-read-only-values read-only-values.cpp)
|
||||
target_link_libraries(issue-212-read-only-values nlohmann_json_schema_validator)
|
||||
add_test(NAME issue-212-read-only-values COMMAND issue-212-read-only-values)
|
||||
|
||||
23
test/read-only-values.cpp
Normal file
23
test/read-only-values.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include <nlohmann/json-schema.hpp>
|
||||
|
||||
using nlohmann::json;
|
||||
using nlohmann::json_schema::json_validator;
|
||||
|
||||
static const json read_only_schema = R"({
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"debug": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"readOnly": true
|
||||
}
|
||||
}
|
||||
})";
|
||||
|
||||
int main() {
|
||||
json_validator validator(read_only_schema);
|
||||
validator.validate(R"({
|
||||
"debug": true
|
||||
})");
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user