Check a folder of type definitions before you register them

Find everything a server would refuse in a folder of type definitions, on your own computer or in a repository's checks, before you register any of them.

marfa types check judges a folder of type definitions by the rules a server applies when it registers a type. It needs no server, key or sign-in, and sends nothing, so it runs the same on your computer and in a repository's checks. Define a type says what a definition holds.

Lay out the folder

Put each definition directly in one folder, in a file named for its type's id, with its guidance beside it if it has any:

types/
  acme.receipt.json
  acme.receipt.md
  acme.expense-report.json
  • <id>.json holds the body marfa types register --file sends. A file named for anything else, even in another case, is refused file_name_mismatch.
  • <id>.md is the type's guidance, read as marfa types register reads it. A Markdown file named for a type with no definition beside it is refused; any other, such as a README.md, is left alone.
  • Subfolders, names that start with a dot, and edge types are not read.

Run the check

marfa types check types

The check judges each type against the types Marfa ships and the folder's other types, a parent before the types beneath it. It reports every problem in every file at once, each with the file, the path in the definition, and the code and message a server would give. --json prints { ok, checked, refused, files } for a script to read.

It exitsWhen
0A server would register every file.
1A file would be refused, or the folder holds no .json file.
2The path isn't a folder.

Once the check passes, register the types, each parent before the types that name it, as Define a type shows.

What the check can't know

Some rules need an instance. The check can't tell whether an id is already registered, what your key may register, or how large a request the instance takes.

A parent that Marfa doesn't ship and the folder doesn't hold is reported missing, even when your instance has it. A type whose parent is missing, refused or in a loop with it gets the answer a server would give without that parent, with the reason beside it.

The rules are in Checking a folder of type definitions in the contract.

On this page