예제 #1
0
        private ValidationResult CheckSourceAgainstInput(JsonElement input, JsonElement source)
        {
            var result = new ValidationResult(true);

            foreach (var element in source.EnumerateObject())
            {
                result += ValidationEvaluator.Evaluate(() => input.TryGetProperty(element.Name, out _),
                                                       $"Json property '{element.Name}' is missing from the input model.",
                                                       () => new ValidationResult(true));
            }

            return(result);
        }
예제 #2
0
        private ValidationResult CheckInputAgainstSource(JsonElement input, JsonElement stored)
        {
            var result = new ValidationResult(true);

            foreach (var element in input.EnumerateObject())
            {
                var value = new JsonElement();
                result += ValidationEvaluator.Evaluate(() => stored.TryGetProperty(element.Name, out value),
                                                       $"Json property '{element.Name}' is missing from the stored data definition.",
                                                       () => ValidationEvaluator.Evaluate(() => element.Value.ValueKind == value.ValueKind,
                                                                                          $"Json property {element.Name} has a differing data type.",
                                                                                          () => new ValidationResult(true)));
            }

            return(result);
        }