hen 0.21.0

Run protocol-aware API request collections from the command line or through MCP.
Documentation
---
sidebar_position: 9
title: Schema Validation
description: Validate a response body against collection-local scalar and schema declarations.
---

Source file:
[examples/schema_object_validation.hen](https://gitlab.com/ben_goodman/apps/hen/-/blob/main/examples/schema_object_validation.hen)

## What It Demonstrates

- collection-local declarations
- nested `schema` declarations
- built-in scalar checks such as `UUID`, `EMAIL`, `URI`, and `DATE_TIME`
- schema assertions with `===`

## Key Pattern

```hen
schema Author {
  id: UUID
  name: string
  email: EMAIL
  avatar: URI
}

schema Article {
  slug: string
  title: string
  subtitle?: string
  image: URI
  author: Author
  content: string
  dateCreated: DATE_TIME
}

^ & body === Article
```

## Run It

```bash
hen verify ./examples/schema_object_validation.hen
hen run ./examples/schema_object_validation.hen 0 --non-interactive
```

## What To Notice

- The declarations live in the collection preamble before the first `---`.
- The assertion stays concise even when the object shape is nested.
- Use the schema examples together with the scalar and root-array examples in `examples/` when you
  need deeper coverage.

Related reference: [Schemas](../reference/schemas.md)