Validation Schemas

Overview

JSON Schema Validation allows you to enforce a consistent structure for image metadata when uploading images to projects. By defining a JSON schema at the project level, you ensure that all uploaded metadata adheres to the required structure. If the metadata does not match the schema, the upload will be rejected with a clear validation error, preventing inconsistent or incomplete data from entering your project.

Use Case Example

Imagine you're uploading images to a project where each image needs specific metadata:

  • Camera settings (ISO, aperture, shutter speed)

  • Location information (GPS coordinates, address)

  • Quality metrics (brightness, contrast, sharpness)

Without validation, different team members might upload images with inconsistent metadata structure. With JSON schema validation, you ensure all metadata follows the same format.

Setting Up Validation

Step 1: Define Your Schema

Create a JSON schema that defines the required structure for your image metadata. For example:

{
  "type": "object",
  "required": ["camera", "location", "quality"],
  "properties": {
    "camera": {
      "type": "object",
      "required": ["iso", "aperture"],
      "properties": {
        "iso": {"type": "number"},
        "aperture": {"type": "string"},
        "shutter_speed": {"type": "string"}
      }
    },
    "location": {
      "type": "object",
      "required": ["lat", "lng"],
      "properties": {
        "lat": {"type": "number"},
        "lng": {"type": "number"},
        "address": {"type": "string"}
      }
    },
    "quality": {
      "type": "object",
      "properties": {
        "brightness": {"type": "number"},
        "contrast": {"type": "number"}
      }
    }
  }
}

Step 2: Set Schema for Project

Apply the schema to your project using the API:

Step 3: Upload Images with Validation

When uploading images, enable validation to ensure metadata compliance:

Validation Options

Standard Validation

Strict Validation

Optimized Validation with Caching

Validating Existing Projects

For projects with existing images, you can validate all current data:

This process helps you:

  • Identify non-compliant images in existing projects

  • Get detailed error reports for each failed image

  • Fix metadata issues before enforcing strict validation

Benefits

  • Consistency: All images have the same metadata structure

  • Quality Control: Prevent incomplete or incorrect metadata uploads

  • Team Coordination: Everyone follows the same metadata standards

  • Data Integrity: Maintain clean, structured datasets

  • Error Prevention: Catch metadata issues at upload time

Common Schema Patterns

Simple Required Fields

Nested Structures

Optional Fields with Defaults

Complete Example

Here's a full workflow example:

Best Practices

  • Start simple: Begin with basic required fields, add complexity gradually

  • Document your schema: Include field descriptions and examples

  • Test thoroughly: Validate your schema with sample data before deployment

  • Version your schemas: Track changes when updating validation rules

  • Communicate changes: Inform team members about new validation requirements

Requirements

  • Supervisely instance version: 6.12.5 or later

  • Supervisely Python SDK: 6.73.228 or later

Last updated