Record types and their rules
A record type is one kind of thing your backend stores, for example an order, a booking or a customer. Each field has a type and rules, and Typestate checks every write against them.
How Typestate does it
- Your agent declares the fields, their types and their rules. You read them back as plain sentences.
- Typestate checks every write, from any action and any caller. It refuses a value that breaks a rule, with a sentence that names the rule.
- Before a change goes Live, Typestate checks the records you already have against the new rules.
What you can do with it
- Keep an order's status to paid, shipped or returned.
- Link an order to the customer who placed it.
- Let people read only their own records.
- Delete old records after a set number of days.
What Typestate gives you
- Field types
- text, whole number, number, yes or no, date, date and time, JSON
- Formats
- email, web address, phone, slug, currency, country
- Rules
- required, unique, range, length, one of a list, pattern, default
- Who may read and write
- anyone, people signed in, the owner, a role, a key
- How long records are kept
- for as long as the service runs, or 1 day to 10 years
Say this to your agent
Add an Order with a total in euros and a status of paid, shipped or returned. Only its customer may read it.