Share via


JsonExtensions.IsValid Method

Definition

Validates the properties of the given JSON object, enforcing the presence of required properties and ignoring the order of properties.

public static bool IsValid (this Newtonsoft.Json.Linq.JObject obj, System.Collections.Generic.IEnumerable<string> requiredProperties, Func<Newtonsoft.Json.Linq.JProperty,bool> isPropertyValid);
static member IsValid : Newtonsoft.Json.Linq.JObject * seq<string> * Func<Newtonsoft.Json.Linq.JProperty, bool> -> bool
<Extension()>
Public Function IsValid (obj As JObject, requiredProperties As IEnumerable(Of String), isPropertyValid As Func(Of JProperty, Boolean)) As Boolean

Parameters

obj
Newtonsoft.Json.Linq.JObject

The JSON object to validate.

requiredProperties
IEnumerable<String>

The names of all JSON properties that are expected to be present in the given object.

isPropertyValid
Func<Newtonsoft.Json.Linq.JProperty,Boolean>

A predicate that determines whether the name and value of given JProperty are valid.

Returns

true if all properties of the given JSON object pass the given validation function and all required properties exist, false otherwise.

Applies to