Menu

1 / 2

Conditional logic in data contracts: Okyline vs JSON Schema

DEV Community·Pierre-Michel Bret·6 months ago
#Jyh0aNMc
#api#showdev#number#fields#required
Reading 0:00
15s threshold

In the first article of this series , we introduced Okyline — a JSON validation language where your examples become your schemas. We walked through an e-commerce order, from a bare JSON payload to a fully constrained contract with computed business rules.

This time, we're going deeper into one specific area: conditional logic . The rules that say "this field is required when that field has this value" or "these fields change depending on the variant". The kind of rules every real-world API has, and the kind that turn JSON Schema into something nobody wants to read.

We'll use a hotel reservation as a running example and build the contract step by step.

The starting point

Here's a simplified hotel reservation payload.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.