コード例 #1
0
        public Diagnostic ValidatePropertyDefinition(IDictionary <string, object> definition)
        {
            if (RootValidator == null)
            {
                throw new Exception("Could not find valid validator for schema validation.");
            }

            return(new Diagnostic()
            {
                IsValid = RootValidator.IsValid(definition),
                Error = RootValidator.Status.Error
            });
        }
コード例 #2
0
        public Diagnostic ValidatePropertyDefinition(string json)
        {
            object obj;

            if (!Properties.Serialization.Json.TryDeserializeObject(json, out obj))
            {
                throw new Exception("Invalid JSON data.");
            }
            if (RootValidator == null)
            {
                throw new Exception("Could not find valid validator for schema validation.");
            }
            return(new Diagnostic()
            {
                IsValid = RootValidator.IsValid(obj as IDictionary <string, object>),
                Error = RootValidator.Status.Error
            });
        }