JsonSchemaValidation.h (958B)
1 // Copyright (c) Microsoft Corporation. 2 // Licensed under the MIT License. 3 #pragma once 4 #include <json/json.h> 5 6 namespace AppInstaller::JsonSchema 7 { 8 // Load schema as parsed json doc 9 Json::Value LoadSchemaDoc(std::string_view schemaStr); 10 11 // Load an embedded resource from binary and return as Json::Value 12 Json::Value LoadResourceAsSchemaDoc(PCWSTR resourceName, PCWSTR resourceType); 13 14 // Populate a valijson Schema object from a json value 15 void PopulateSchema(const Json::Value& schemaJson, valijson::Schema& schema); 16 17 // Validate a json doc with a schema 18 // Returns whether it was successful and fills the results object 19 bool Validate(const valijson::Schema& schema, const Json::Value& json, valijson::ValidationResults& results); 20 21 // Extracts the error messages from a result into a single non-localized string 22 std::string GetErrorStringFromResults(valijson::ValidationResults& results); 23 }