Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ string schemaJson = "{\"properties\":{\"Name\":{\"maxLength\":7}}}";
---
**Example: Validate nested elements of an array**
<Tabs groupId='languageSyntax'>
<TabItem value="Validation_schema" label="Validation_schema">
<TabItem value="Schema_as_string" label="Schema as string">

```csharp
// Validate properties of documents in the Orders collection
Expand Down Expand Up @@ -83,6 +83,46 @@ string schemaDefinition = @"{
}";
```
</TabItem>

<TabItem value="JSON_schema" label="JSON_schema">

```json
{
"additionalProperties": true,
"properties": {
"Company": {
"type": "string",
"minLength": 1
},
"Lines": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": true,
"properties": {
"Product": {
"type": "string"
},
"Quantity": {
"type": "integer",
"minimum": 1
}
},
"required": [
"Product",
"Quantity"
]
}
}
},
"required": [
"Company",
"Lines"
]
}
```
</TabItem>

<TabItem value="Example_document" label="Example_document">

```json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Manage [schema validation](../../../documents/schema-validation/overview) using
* [Creating a collection schema](../../../documents/schema-validation/write-validation/write-validation_studio#creating-a-collection-schema)
* [Managing and Testing existing schemas](../../../documents/schema-validation/write-validation/write-validation_studio#managing-and-testing-existing-schemas)
* [The schema playground](../../../documents/schema-validation/write-validation/write-validation_studio#the-schema-playground)
* [Validating a specific document](../../../documents/schema-validation/write-validation/write-validation_studio#validating-a-specific-document)

</Admonition>

Expand Down Expand Up @@ -181,7 +182,18 @@ To create and test schemas in a secluded environment, without affecting your pro

</Panel>

<Panel heading="Validating a specific document">

To validate a specific document against the schema defined for its collection, open the [document view](../../../studio/database/documents/document-view#the-document-view), select the document, and click the **Validate document** button.
* The validation button will be displayed only if a schema is defined for the document's collection.
* To validate a whole collection, use the **Document Schema** view [Test](../../../documents/schema-validation/write-validation/write-validation_studio#managing-and-testing-existing-schemas) as described above.

![Validate document button](./assets/schema-validation_studio_validate-document-button.png)

If the document fails the validation, an alert will appear.
![Validation alert](./assets/schema-validation_studio_validate-document-alert.png)

Click the alert to view the validation errors.
![Validation errors](./assets/schema-validation_studio_validate-document-errors.png)

</Panel>