Property
A Property item inside a Schema declares a single field on a governed type — its name, type, cardinality, default, uniqueness, references, cascade behaviour, group membership, and resolvers.
When to reach for it
Declare a Property for every itemprop on a governed type that should be checked, defaulted, transformed, or constrained. An undeclared property has no declaration-specific type or cardinality check. The schema does not implicitly reject extra properties, but schema-level validators or applicable shape constraints can still inspect or restrict them. Neither an undeclared field nor an accepted type check establishes that markup is safe to render.
Shape
A property is a nested [itemscope] inside a schema, linked via itemprop="property".
<div itemprop="property" itemscope itemtype="https://pagelove.org/Property">
<meta itemprop="name" content="email">
<meta itemprop="type" content="https://schema.host/Text">
<meta itemprop="cardinality" content="1..1">
<meta itemprop="default" content="user@example.com">
<meta itemprop="unique" content="true">
<meta itemprop="references" content="https://example.com/Org#identifier">
<meta itemprop="cascade" content="restrict">
<meta itemprop="group" content="contact-info">
<script type="text/sessel" itemprop="@validate">
self.all((el) => el.text().matches("^[^@]+@[^@]+\\.[^@]+$"))
</script>
</div>
Fields
| Field | Cardinality | Accepts | Purpose |
|---|---|---|---|
name |
1..1 |
Text | Matches the itemprop on data items. A property with no name is silently skipped. |
type |
0..1 |
URL | A primitive type URL from schema.host or another schema's governed type URL. When omitted, no type validation runs. |
cardinality |
0..1 |
Text | 0..1, 1..1, 0..n, 1..n. Defaults to 0..n. Write 0..n or 1..n out and the property reads as a list — see below. |
description |
0..1 |
Text | Human-readable description for tooling and error messages. |
default |
0..1 |
Text or Sessel item | Value injected when the property is absent on a write. See below. |
unique |
0..n |
Text | "true" for individual uniqueness; any other string is a group name. Properties that share a group name share one set of unique values. |
references |
0..1 |
Text | Foreign key in the form {itemtype}#{itemprop}. The target must be declared unique: true. |
cascade |
0..1 |
Text | "true" (cascade delete) or "restrict" (block delete). Requires references. |
group |
0..n |
Text | Group name(s) for required combinations. |
@validate |
0..1 |
Sessel or JavaScript binding | Sessel must return the Boolean true; JavaScript must return a truthy value. In Sessel self is always the list of the property's elements; in JavaScript the first argument is the property's first value. Runs when the relevant item or property is validated on an application write, and once when server code builds an instance with new. WebDAV writes skip it. See Resolvers. |
@write |
0..1 |
Sessel or JavaScript binding | Transforms property values before storage. It can refuse a write by throwing an HTTPResponse. See Resolvers. |
@read |
0..1 |
Sessel or JavaScript binding | Transforms property values on read. See Resolvers. |
@key |
0..1 |
Boolean ("true" / "false") |
Marks this property as the schema's primary key. The instance's value for this property is emitted as id="…" on the root element when the instance is materialised via Pagelove.PUT. Requires unique: "true" on the same property. See below. |
Reading a multi-valued property
A property whose schema spells out 0..n or 1..n reads as a list when you
read it from a typed item. An absent property is an empty list, a single value is
a one-element list, and several values are a list of several. The shape does not
depend on how many values a particular item happens to hold.
You have to write the cardinality out. Leaving it off means 0..n for
validation, but such a property keeps reading as a plain value — so no schema
already in use changes shape underneath the pages that read it. If you want a
property to read as a list, say 0..n or 1..n in the schema.
One route does not do this yet: a property read off an element returned by a
selector query still gives you a plain value when there is exactly one, because
such an element carries no schema. Until that is finished you still need to
coerce on that route — see #1394. On that route you do get every value when
there is more than one; earlier releases returned only the first. A value
written as element text rather than as a content attribute is also read on
that route now, where earlier releases read it as empty.
That loop is correct whether the user has no addresses, one, or five. You do not need to coerce the value first.
This matters more than it may look. If a single value read back as a plain string, the same template would be right for two addresses and wrong for one — and one is the common case for most properties. Worse, the mistake is invisible until a document happens to have the other number of values.
Single-valued properties (0..1, 1..1) are unaffected: they read as plain
values, not one-element lists. So do properties with no cardinality at all.
Cardinality values
| Value | Meaning |
|---|---|
0..n |
Any number of values allowed. Default when cardinality is omitted. |
0..1 |
At most one value. |
1..1 |
Exactly one value required. |
1..n |
At least one value required. |
Cardinality counts [itemprop="<name>"] elements within the item's scope, excluding anything inside nested [itemscope] boundaries.
Type
When type is a primitive URL (https://schema.host/Text, Number, Integer, Boolean, Date, DateTime), each value is format-validated against the rules for that type — see Types.
A schema URL in type does not by itself establish recursive enforcement of a nested item's schema or require its itemtype to match. In tested application whole-document PUTs, a parent with an Address-typed property accepted a nested wrong type, a bad or absent child integer, and plain text. The same invalid integer was rejected when the Address was saved as a top-level item; omitting the parent's required property was also rejected. Test explicit nested-content checks on your actual write path instead of relying on the declaration alone. See nested schema types.
Omitting type disables the property's type check. Cardinality, custom validators, uniqueness, references and other applicable rules can still refuse the write; omission is not unconditional acceptance.
If an item names several types, every governing schema checks it. When two of those schemas declare the same property with types no value can satisfy together, the write is refused whatever the value. See Items with several types.
Defaults
A static default is a literal value, injected as <meta itemprop="..." content="..."> when the property is absent on a write:
<meta itemprop="default" content="draft">
A dynamic default is an expression evaluated at write time, written in either Sessel or JavaScript. The language is selected by the itemtype URL on the wrapper:
<div itemprop="default" itemscope itemtype="https://pagelove.org/Sessel">
<script itemprop="source" type="text/sessel">String.random(8)</script>
</div>
<div itemprop="default" itemscope itemtype="https://pagelove.org/JavaScript/Module">
<script itemprop="source" type="module">
export default () => String(Math.floor(100 + Math.random() * 500));
</script>
</div>
Dynamic defaults run server-side, before validation. The Sessel form is a bare expression; self is unavailable because the item does not yet contain the property. The JavaScript form is an ES module whose default export is a function; this is bound to the in-progress instance and a context object is passed as the first positional argument. See JavaScript bindings for the full JavaScript contract.
Child defaults override parent defaults for the same property name.
The same JavaScript/Module source is also used by the pagelove.mjs client-side runtime when discovering schemas in the browser — see Schema definitions in HTML.
Uniqueness
unique: "true" declares individual uniqueness — no two items of this governed type on the host may have the same value for this property.
Any other string is a group name. Properties that share a group name share one set of unique values for the governed type on the host. No value may appear twice in that set, whichever member property holds it and whichever item it is on.
<meta itemprop="unique" content="host-names">
The rule covers each value on its own:
- a value held by one member property on one item cannot be held by the same or another member property on any other item
- a value cannot appear twice on one item, so a host whose
aliasequals its ownhostnameis refused with 422 - each value of a property that allows several values counts on its own
Values compare exactly, as text, so Example.com and example.com are different values. If you want names to match whatever their case, lower-case the value in the schema, for example with a property @write or @validate.
A property can take part in both individual and group uniqueness:
<meta itemprop="unique" content="true">
<meta itemprop="unique" content="host-names">
A group with one member property behaves exactly like unique: "true" on that property. Hostnames and aliases that share one set of names shows a worked example.
Uniqueness is enforced atomically with the write. The rule belongs to the type that declares it, and covers that type and every type beneath it — see the next section.
If the database fails while a save or delete checks uniqueness, a reference, or a restrict or cascade rule, the save or delete fails with the server-fault response and changes nothing: a save stores nothing and a delete keeps the page. The status is 500 for a damaged page, 504 for a timeout and 503 for any other database failure. The failed check never counts as "no duplicate", "no such target" or "nothing refers to this value". Where a check has to read many pages of the site, it stops at a limit of its own (100,000 operations, which is enough for one search over about 200 pages of 20 items with 8 properties each). All the checks of one save or delete share that one limit within one call to the storage layer, so a save that runs several searches reaches it on a smaller site. A whole-document MOVE runs the source's delete checks twice under one limit, so a source whose checks use more than half of it is refused with 503 before anything is written, even where a DELETE of the same page succeeds. The server sometimes has to run an element write again because a concurrent write changed the page, up to 16 times. Each of those runs starts a new limit. When a save or delete goes over it, it fails with 503 and the https://pagelove.org/BudgetLimit document. A refused save seeds no counter, so later saves over HTTP under the same uniqueness, group, cascade or restrict rules fail the same way until the operator runs dombase-util reindex. A reference check searches whenever no page is recorded as holding the value, whatever the counters say, so on a site past the limit a save that names a value no page holds fails with 503, and a re-index does not change that. A delete, or a change of a referenced value, under a reference rule whose index is being rebuilt also searches the whole site, and can get the same 503 until the rebuild finishes. It does the same under a reference rule whose rebuild record is damaged, and under one that your site has no rebuild record for, until your operator runs dombase-util reindex for the site. A rule has no record when its registration failed, when its schema was saved before the schema of the type it references, when it comes from the shared schemas of a separate schema host and your site never saved a schema for its type, or when it depends on the shared schemas and was saved over WebDAV. Under a rule whose index is trusted, a delete, a cascade or a change of the referenced value reads each page the index names to confirm it refers under that rule, and those reads count against the same limit, so a value that very many pages refer to can also get the 503. A delete of one page that keeps its transaction open for more than 5 seconds while it searches fails with 504 at once. A save of a web page fails with 504 after its 30-second publish deadline, sometimes longer. A delete that a concurrent write makes conflict, for example a referring page saved while the delete ran, fails with 409 and the WriteContention document, and you can send it again. A delete sent with If-Match that loses to a concurrent write of that page also gets 409, and sending it again gets 412, because the page has changed. When the race was a referring page or a save of the same family, the page did not change and sending it again succeeds. A WebDAV save or delete runs none of these checks, so none of them can fail it, and no restrict or cascade rule ever refuses a WebDAV delete, even for a record that a restrict rule protects. Another WebDAV rule, such as a lock, can still refuse it. A database fault while it updates the indexes still fails the save or delete, as it fails any write.
A save of a whole page has a limit of 5 minutes, from its first step to the moment it switches the page. A save that passes the limit fails with 504, stores nothing and leaves the page as it was, and you can send it again.
What a refusal says about other pages
A refused save tells you which rule it broke. It does not tell you which other page holds the value. The error names no page except the one you asked for, and where it would name another page it says another page:
<span itemprop="message">Uniqueness violation: value already exists for property 'email' at 'another page'</span>
A refusal under a group says the same: value already exists in group 'unique-host-names' at 'another page'. When the other holder is an item on the page you wrote, the error names that page, because it is the one you asked for.
Text you sent yourself, such as a selector, can look like a page path. If it does, and it is not the page you asked for, the error may show another page in its place. The exact rule is in Other pages in a platform error in the protocol specification.
The status and the error's itemtype do not change. A refused delete under a restrict rule names no other page either: it counts the pages that refer to the value and does not list them. The same holds for every error the platform builds, such as the error page of a trigger or processor that fails. An error a script builds is left as the script wrote it. The server log keeps the full text of any error the platform changed, so an operator can find the page.
Which item holds a value
A unique value belongs to the item the property is a property of. A property inside a wrapper element, such as a div, belongs to the item around the wrapper. A value inside a nested item of another type belongs to that nested item, so it does not clash with the outer item. A value named through itemref belongs to the item that names it. An element with an itemtype but no itemscope is not an item. Which elements are an item's properties has the full rule.
Uniqueness covers every type beneath the one that declares it
A property declared unique on a type is unique across that type and every type that inherits from it. If Organization declares regno unique, and Charity inherits from Organization, then a charity and an organisation cannot both hold the registration number 12345. Two charities cannot either.
The same rule applies to a group. The values of a group are unique across the declaring type and its descendants, so two records of different subtypes cannot hold the same value.
This is a tightening. Before, a value claimed by one type could be claimed again by a type beneath it. If your site already holds two such records, both keep serving. The next save of either one is refused, and the refusal names the property. To clear it, change or remove one of the values.
A rule can prevent an application save. WebDAV authoring bypasses application constraints and can be used to repair that content. It is not a universal recovery guarantee: request, routing, storage and metadata failures can still prevent authoring. In the isolated stack documented in the WebDAV verification scope, an unreadable local Schema also blocked attempted repair writes before persistence. Use the observed error and that deployment’s recovery procedure instead of assuming another upload will succeed.
Uniqueness and cardinality are different rules
Uniqueness says no two items share a value. Cardinality says how many values one item may hold. The two are independent, so a property can be unique and still hold several values.
Take a Person whose email property is declared unique and 0..n:
<li itemprop="property" itemscope itemtype="https://pagelove.org/Property">
<meta itemprop="name" content="email">
<meta itemprop="cardinality" content="0..n">
<meta itemprop="unique" content="true">
</li>
One person may hold a@example.com and b@example.com, and no other person may claim either address.
What an item may not do is list the same value twice:
<div itemscope itemtype="https://example.com/Person">
<meta itemprop="email" content="a@example.com">
<meta itemprop="email" content="a@example.com">
</div>
That write is refused as a uniqueness violation, naming the property and the item. It is newly refused: before, the repeat was accepted and the second copy was ignored.
A group belongs to the highest type that declares it
A group belongs to the highest type that declares any of its members, and covers that type and every type beneath it.
So if a parent type declares hostname in a group and a child type declares alias in the same group, the parent's hostname and the child's alias share one set of unique values. Only a type that declares a member of the group can own it. If two sibling types each declare a member of a group of the same name, and their common parent declares none, they have two separate groups, and a value can appear once in each. The same holds for two types with no common ancestor. If you want one shared set of values, declare the members on one type that sits above all the types concerned.
References and cascade
references declares a foreign key. The value format is {itemtype}#{itemprop}, pointing at a property that is declared unique: true on the target type. Every value of the referencing property must match an existing value on some item of the target type.
Subtypes count. An item whose schema declares the target as an ancestor satisfies the reference, because an item of a subtype is an item of the target type. So a reference to Plan is satisfied by a Plan:Free record, and you do not need to keep a bare-typed record for the reference to land on. Only declared descendants qualify — an unrelated type carrying the same value does not.
<meta itemprop="references" content="https://example.com/Org#identifier">
<meta itemprop="cascade" content="restrict">
cascade value |
Behaviour on delete of the referenced value |
|---|---|
"true" |
Cascade: delete referencing items (or clear the reference based on cardinality). |
"restrict" |
Block the operation. A restrict-blocked DELETE returns 409 Conflict. |
omitted / "false" |
No cascade behaviour. |
A page counts as referring to a value under restrict even while its cascade update to that value is still waiting to be applied, so a delete can be refused when no page visibly holds the value yet.
If several referencing types point at the same source property and any one of them uses restrict, every cascade rule for that source is upgraded to restrict. Data integrity is never silently violated.
What triggers a cascade
A cascade fires when the referenced value disappears or changes through a schema-valid operation:
DELETEof the document holding the referenced value.- A write that removes or changes the referenced value, where the resulting document still satisfies its own schema.
Removing the only value of a 1..1 property is not schema-valid — the document would be left violating its own cardinality — and is rejected with 422 Unprocessable Content before any cascade is considered. The SQL analogue: cascade is a referential action on deleting the row, not on setting a NOT NULL key to NULL. To remove a 1..1 referenced value and cascade, delete the whole document. For 0..1 / 0..n referenced properties, removing the value element (e.g. a selector DELETE) is schema-valid and triggers the cascade.
What the cascade does to referrers
When a cascade fires, each referencing item's disposition is determined by the referencing property's cardinality:
| Referencing cardinality | Action |
|---|---|
1..1 |
The referencing document is deleted. |
0..1 / 0..n |
The referencing property element is removed; the document survives. |
1..n |
The matching value element is removed; if it was the last one, the document is deleted. |
When the referenced value changes (rather than disappears), cascade: "true" rewrites the referencing property values to the new value.
A referencing document that is deleted goes in the same step as the change that caused it. One that is updated or cleared is rewritten just after that change is saved, so a read made straight afterwards can briefly show the old value. The rewrite is not lost: if it fails, the server retries it until it succeeds. If you edit the referencing document before the rewrite lands, your edit is kept and the rewrite is applied on top of it. If your edit already changed or removed the old value, there is nothing left to update and the rewrite is dropped.
A cascade that updates or clears a referencing document counts as a change to that document. Any element ETag you read from it before the cascade no longer matches, so a conditional write that sends one in If-Match gets 412 Precondition Failed, even if the cascade did not touch that element. Read the element again and retry.
Documents saved over WebDAV count too
A referencing document counts for restrict and cascade however it was saved: through the web, over WebDAV, through a mounted folder, or moved or copied. WebDAV still saves exactly what you give it — it does not check that the record a reference names exists — but it records the reference. So once that record exists, restrict protects it and a change to its value reaches your document.
Primary key
@key: "true" declares that this property's value is the schema's primary key. When an instance is materialised via Pagelove.PUT, the property's value is written as the id attribute on the instance's root element.
<li itemprop="property" itemscope itemtype="https://pagelove.org/Property">
<meta itemprop="name" content="hid">
<meta itemprop="type" content="https://schema.host/Text">
<meta itemprop="cardinality" content="1..1">
<meta itemprop="unique" content="true">
<meta itemprop="@key" content="true">
</li>
A Host instance constructed and PUT through Sessel:
let h = new Host { hid: "abc123", hostname: "abc123.example.com" };
Pagelove.PUT(h, "/hosts/abc123.html")
Persists with the keyed id on the root:
<div id="abc123" itemscope itemtype="https://example.com/Host">
<meta itemprop="hid" content="abc123">
<meta itemprop="hostname" content="abc123.example.com">
</div>
Requirements
| Condition | Behaviour |
|---|---|
@key: "true" AND unique contains "true" |
Honoured. |
@key: "true" on a property that is not individually unique |
Ignored. |
@key: "true" on a property whose cardinality is not 1..1 |
Ignored. |
Group unique="<group-name>" only (no individual "true") |
Does not qualify — same as above. |
Two or more properties on one schema declare @key: "true" |
Document order wins. |
Schema's own properties have no @key; parent schema declares one |
Parent's @key applies (inheritance). |
No @key anywhere in the inheritance chain |
No id is set on the materialised root; current behaviour preserved. |
A keyed property must be declared cardinality: "1..1". A key names one item by one value, so a property that may hold several values does not identify anything, and one that may hold none identifies nothing at all. An omitted cardinality allows any number of values, so it does not qualify either.
This changed. If you have a @key on a property with no declared cardinality, no id is set now. Before, the id was whichever value came first in the document. Add <meta itemprop="cardinality" content="1..1"> to the property to get the id back.
Value rules
The keyed value is emitted verbatim as the id attribute. Two value-shape rules apply at PUT time:
| Value shape | Behaviour |
|---|---|
| Non-empty, no whitespace | Emitted as id="<value>". Any pre-existing id on the root is overwritten. |
| Empty | No id is emitted. |
| Contains whitespace | No id is emitted (whitespace breaks #id selectors). |
| Several values on one item | Cannot arise: a keyed property must be 1..1. |
| Property is a computed property | No stored value at materialisation time; no id is emitted. |
Inheritance
@key is inherited from parent schemas. The resolver walks the schema's own properties first (document order, first wins on duplicates), then the parent's properties, and so on up the chain. A child schema can declare its own @key to override the parent's.
Auto-generated default
A property marked @key="true" with no explicit default automatically gets a Sessel default that produces an 8-character value at instance construction. The first character is always a lowercase letter ([a-z]) and the remaining 7 are lowercase-alphanumeric ([a-z0-9]) — this guarantees the value is a valid CSS #id selector (CSS identifiers cannot start with a digit). So:
<li itemprop="property" itemscope itemtype="https://pagelove.org/Property">
<meta itemprop="name" content="hid">
<meta itemprop="type" content="https://schema.host/Text">
<meta itemprop="cardinality" content="1..1">
<meta itemprop="unique" content="true">
<meta itemprop="@key" content="true">
</li>
Behaves as if you had written:
<li itemprop="property" itemscope itemtype="https://pagelove.org/Property">
<meta itemprop="name" content="hid">
<meta itemprop="type" content="https://schema.host/Text">
<meta itemprop="cardinality" content="1..1">
<meta itemprop="unique" content="true">
<meta itemprop="@key" content="true">
<div itemprop="default" itemscope itemtype="https://pagelove.org/Sessel">
<script itemprop="source" type="text/sessel">
String.random(1, { lower: true }) + String.random(7, { lower: true, digits: true })
</script>
</div>
</li>
new Host {} (no hid) materialises with a random hid like "k3p9zx2m" (always letter-first), the cardinality 1..1 is satisfied, and Pagelove.PUT writes the instance with id="k3p9zx2m" on the root.
To override, declare an explicit default on the property, or pass an explicit value at construction (new Host { hid: "abc123" }).
Computed properties skip the auto-default — they have no stored value to default. Declaring both @key: "true" and a computed binding on the same property has no effect: no auto-default is synthesized, and the property remains computed.
Computed properties
A computed property has no stored value: its value is calculated every time the property is read, from the rest of the instance. Attempting to write a value to a computed property fails — the write is rejected with an error rather than silently accepted.
The current mechanism is an @computed slot, in either Sessel or JavaScript:
<div itemprop="property" itemscope itemtype="https://pagelove.org/Property">
<meta itemprop="name" content="display-name">
<div itemprop="@computed" itemscope itemtype="https://pagelove.org/Sessel">
<script itemprop="source" type="text/sessel">
self.first-name + " " + self.last-name
</script>
</div>
</div>
<div itemprop="property" itemscope itemtype="https://pagelove.org/Property">
<meta itemprop="name" content="full-name">
<div itemprop="@computed" itemscope itemtype="https://pagelove.org/JavaScript/Module">
<script itemprop="source" type="module">
export default function() { return this.firstName + " " + this.lastName; }
</script>
</div>
</div>
In Sessel, self refers to the whole instance. In JavaScript, this refers to the whole instance (a function form is required — an arrow function does not bind its own this). Either way the expression sees the instance's other properties, not a list of property elements. If a property has both @computed and @read, @computed takes precedence and @read never fires for it. See Resolvers for how @read/@write transformers differ from a computed property, and JavaScript bindings for the JavaScript contract.
Legacy syntax: @read wrapped in bare Sessel
An older, Sessel-only shorthand is still recognized for backward compatibility: an @read slot whose typed item is the bare https://pagelove.org/Sessel type (not Sessel/Lambda) is parsed as a computed property rather than a read transformer:
<div itemprop="property" itemscope itemtype="https://pagelove.org/Property">
<meta itemprop="name" content="display-name">
<div itemprop="@read" itemscope itemtype="https://pagelove.org/Sessel">
<script itemprop="source" type="text/sessel">
self.first-name + " " + self.last-name
</script>
</div>
</div>
New schemas should prefer @computed — it works in both languages and doesn't rely on the reader recognizing which of the two Sessel item types is in play.
Validators
@validate runs when the relevant item or property is checked on a supported application-write path, after defaults and the applicable cardinality and type checks. Do not infer its execution from the HTTP method alone; authoring and operation-specific paths have different checks. When server code builds an instance with new, it runs once in the same check, with the same value. Under new a JavaScript validator cannot read the host's data, so Class.search() finds nothing, and a thrown HTTPResponse becomes an ordinary error for the code that called new. WebDAV writes are never validated.
In Sessel, self is always the list of the property's elements, never a plain value: read a value with self.first().value() or self.first().text(). In JavaScript, the property's first value is the first positional argument. The acceptance rule differs by language: Sessel must return the Boolean true, while JavaScript uses truthiness. In isolated whole-document PUT tests, Sessel refused 1, "yes" and [] with 422, while JavaScript validators returning those values accepted the same valid property. Both languages refused false, 0, "" and null; Boolean true accepted. These cases test this validator boundary, not every write route.
Sessel validator
<div itemprop="@validate" itemscope itemtype="https://pagelove.org/Sessel">
<script itemprop="source" type="text/sessel">
self.all((el) => el.text().matches("^[^@]+@[^@]+\\.[^@]+$"))
</script>
</div>
A Sessel validator sees the surrounding document. parent() on an element in self returns the element that encloses it, upward and sibling traversal reach the rest of the document, and selector() returns a document-absolute selector. So a validator can test where a property sits, not only what it holds:
<div itemprop="@validate" itemscope itemtype="https://pagelove.org/Sessel">
<script itemprop="source" type="text/sessel">
self.first().parent().attr("itemtype") == "https://schema.org/Person"
</script>
</div>
A validator in either language may throw an HTTPResponse to refuse a value with its own status, message, body and headers. With no message and no body, the body carries the status's standard reason phrase, such as Conflict for 409. A header that frames the message or reports its cost, such as Content-Length, is never sent; the Trigger page lists them. The status must be 400 to 599. A thrown response with no status, or any other status, gets the ordinary 422 violation instead, so a refused write is never reported as a success.
What the validator sees is a snapshot taken when the write is checked. A change made through it lands on a copy that is thrown away, so use @validate to accept or refuse a write, never to edit it.
This is a change. A validator used to see the property on its own, cut off from the rest of the document. parent() and upward traversal returned nothing, and selector() described where the property sat in that detached copy rather than in the document.
Most rules get looser. A rule that asked about the surroundings got nothing back, so it failed and refused every write. It now gets an answer, and may accept writes it used to refuse.
One kind of rule gets stricter. A rule that checks the surroundings are absent, such as self.first().parent() == null, was true of every write and so accepted everything. It is now false whenever the property sits inside another element, so those same writes are refused. If your host starts refusing writes it used to accept, look for a validator that asserts there is nothing above the property. A rule that compares selector() with a fixed string changes its answer for the same reason.
JavaScript validator
<div itemprop="@validate" itemscope itemtype="https://pagelove.org/JavaScript/Module">
<script itemprop="source" type="module">
export default (val) => typeof val === 'string' && val.includes('@');
</script>
</div>
A JavaScript validator checks the same writes a Sessel one does, at the same point, and a refused value gets the same 422 response. It receives the property's first value: a string, an object for a nested item, or undefined when the property is absent. Return a truthy value to accept it. WebDAV writes are never validated, in either language.
When a schema uses inheritance, the property's @validate at every level of the chain runs, ancestor first, whatever language each is written in. A child's validator does not replace its parent's: the value must pass both, and every one that refuses it is reported. Group constraints are the exception, where a child's constraint replaces its parent's.
The JavaScript form is the same JavaScript/Module typed item used for defaults and resolvers. See JavaScript bindings for the full contract — export default, supported language features, errors, and resource limits.
Error cases
| Condition | Result |
|---|---|
Property with no name |
Silently skipped during parsing. |
| Cardinality violation | 422 with check: "cardinality". |
| Type validation failure | 422 with check: "type". |
@validate returns anything other than true (Sessel), or a falsy value (JavaScript) |
422 with check: "@validate". |
@validate fails to compile |
422 on every write to the governed type. |
@validate or a dynamic default runs out of the request's time, operations or memory |
503 with the https://pagelove.org/BudgetLimit document. The defaults get what is left of the request's time. When the request has no time limit, the defaults of one saved body share one 5 seconds and its validators share another 5 seconds. The same holds for one item built in code (with new, or returned by a JavaScript method while a page is shown). For a selector write or a MOVE, the validators of one check share one 5 seconds. This holds in both languages, and wherever an item takes its defaults. A JavaScript method run while a page is composed, and a j: expression, that run out of the request's time or operations fail the page the same way. Inside a trigger, processor or transition handler condition, running out takes that place's own outcome instead. |
Malformed references format (missing #, empty type or property) |
Schema load error; every write to the type is rejected. |
references target is not declared unique: true |
Schema load error; every write to the type is rejected. |
| Dynamic default expression fails at write time | 500 with the https://dombase.pagelove.team/ns/error/Internal document; nothing is stored. |
@key: "true" on a property without unique: "true" |
Schema loads successfully; @key is ignored at resolution. |
Two or more @key: "true" declarations on one schema |
Schema loads successfully; document order wins. |
@key value at PUT time is empty or contains whitespace |
PUT proceeds; no id set on root. |
See also
- Schema — the parent schema item
- Types — primitive types and schema-reference types
- Required combinations — group constraints across several properties
- Resolvers —
@readand@writepipeline details - JavaScript bindings — the server-side JavaScript binding contract for
default,@read,@write, and@validate