# JsonValidationResult class
{: .no_toc }

A **JsonValidationResult** is the report of a schema validation: whether the value satisfied the schema, and if it did not, the list of failures. [**Json.Validate**](/tB/Packages/Contributed/tsJson/Json.md#validate) and [**JsonSchema.Validate**](/tB/Packages/Contributed/tsJson/JsonSchema.md#validate) return one, never **Nothing**. A failure of the value is only on the result; it does not set the last error of [**JsonError**](/tB/Packages/Contributed/tsJson/JsonError.md).

```tb check_build check_run
Dim schema As Variant = Json.Parse("{""type"":""object"",""required"":[""id"",""tags""],""properties"":{""id"":{""type"":""integer"",""minimum"":1},""tags"":{""type"":""array"",""items"":{""type"":""string""},""uniqueItems"":true}},""additionalProperties"":false}")
Dim inst As Variant = Json.Parse("{""id"":0,""tags"":[""a"",1,""a""],""extra"":true}")
Dim report As JsonValidationResult = Json.Validate(inst, schema)
Debug.Print report.IsValid
Debug.Print report.ErrorCount

Dim line As Variant
For Each line In Split(report.ToString(), vbLf)
    Debug.Print line
Next
' Output:
' False
' 4
' minimum /id - Number is below minimum.
' uniqueItems /tags - Array items are not unique.
' type /tags/1 - Type is not 'string'.
' false /extra - Schema is false.
```

* TOC
{:toc}

## Properties

### ErrorCount
{: .no_toc }

The number of failures. A **Long**, read-only.

Syntax: *n* **=** *result***.ErrorCount**

### IsValid
{: .no_toc }

Whether the value satisfied the schema. A **Boolean**, read-only.

Syntax: *flag* **=** *result***.IsValid**

Returns **True** when [**ErrorCount**](#errorcount) is 0.

## Methods

### Errors
{: .no_toc }

Returns the failures.

Syntax: *result***.Errors** ( ) **As** [**JsonValidationError**](/tB/Packages/Contributed/tsJson/JsonValidationError.md)**()**

Returns an array of [**JsonValidationError**](/tB/Packages/Contributed/tsJson/JsonValidationError.md) objects, in the order the failures were found, with a lower bound of 0. The array is unbound when the value is valid, so check [**IsValid**](#isvalid) or [**ErrorCount**](#errorcount) first.

```tb check_build check_run
Dim report As JsonValidationResult = Json.Validate(Json.Parse("[1,""x""]"), Json.Parse("{""items"":{""type"":""number""}}"))
Dim errs() As JsonValidationError = report.Errors()
Debug.Print UBound(errs) - LBound(errs) + 1               ' 1
Debug.Print errs(0).Keyword                               ' type
Debug.Print errs(0).InstancePointer                       ' /1
Debug.Print errs(0).SchemaPointer                         ' /items/type
Debug.Print errs(0).Message                               ' Type is not 'number'.
```

### ToString
{: .no_toc }

Returns the report as text.

Syntax: *text* **=** *result***.ToString** ( ) **As String**

Returns `valid` when there is no failure. Otherwise returns one line for each failure, separated by a line feed (`vbLf`), each line as [**JsonValidationError.ToString**](/tB/Packages/Contributed/tsJson/JsonValidationError.md#tostring) writes it.

## See Also

- [JsonValidationError](/tB/Packages/Contributed/tsJson/JsonValidationError.md) class -- one failure
- [JsonSchema](/tB/Packages/Contributed/tsJson/JsonSchema.md) class -- validates a value against a compiled schema
- [Json](/tB/Packages/Contributed/tsJson/Json.md#validate) module -- **Validate** for a single check
- [tsJson Package](/tB/Packages/Contributed/tsJson/index.md) -- the package
