Skip to content

YAMLSchema Cheat Sheet

The compact forms used most often when writing .ysd.yaml files.

Fields

name: +Str       # required
email?: +Str     # optional

The key mirrors the data key. Add ? only when the field is optional.

Built-in types

anything: +Any
text: +Str
count: +Int
number: +Num
float: +Float
enabled: +Bool
nothing: +Null

JSON Schema formats

birthday: +JSON-Schema/date
created: +JSON-Schema/date-time
email: +JSON-Schema/email
host: +JSON-Schema/hostname
id: +JSON-Schema/uuid

Numeric ranges

port: +Int 1..65535
zero_or_more: +Int 0..
percentage: +Num 0..100
upper_bound?: +Num ..10

Strings and patterns

code: +Str 3..12
whole: +Str ~"{upper}+"
contains: +Str ~~"{digit}+"

~"..." matches the complete string. ~~"..." searches within it.

Constants and enums

kind: +Str ==person
role: +Str [admin, user, guest]
answer: [true, false, 42]

Lists

names: +Str[]
tags: +Str[1+]
pair: +Int[2]
unique: +Str[!1+]
maybe_one: +Str[$]

Mapping shapes

person:
  name: +Str
  age?: +Int 0..

labels: +Map{+Str}
metadata: +Map{}

Shaped mappings are closed by default.

Open mappings

.open: true

closed:
  .open: false
  fixed: +Str

typed:
  fixed?: +Str
  +Str: +Int

Definitions

+email: +JSON-Schema/email
+address:
  street: +Str
  city: +Str

contact: +email
home: +address

References

local: +address
external: +Ref(profile.schema.json)

detailed:
  -: External profile
  .xref: https://example.com/profile.schema.json

Nullability

maybe_text: +Str~
maybe_list: +Str[]~
optional_nullable?: +Int~

? controls presence. ~ permits a null value.

Dependencies

postOfficeBox?: +Str :need(streetAddress)
streetAddress?: +Str

If postOfficeBox is present, streetAddress must also be present.

Combinators

value: +One(+Str,+Int)
choice: +Any(+Str,+Bool)

values:
  .any[]:
  - +Str
  - +Int

.one:
- kind?: +Str ==person
- kind?: +Str ==company

Annotations

--: Person
-: A person record

name: +Str -"Display name"
age:
  -: Age in years
  .type: +Int

File forms

contact.ysd.yaml
contact.ysdc.yaml
contact.ysdc.json
contact.schema.json

.ysd is authored. .ysdc is canonical. JSON Schema is interchange.