SerializationSchema
interfaceA `SerializationSchema` is a Parse (so it can be called directly to coerce a value and dropped straight into createState's `parse` option) that also carries its recoverable default and an introspectable meta description of its domain. Schemas are built with stringValue, numberValue, booleanValue, enumValue, nullable, and composed into whole-object schemas with objectValue — nodeSchema for a node's own, which is where accessors are named.
Import
import { SerializationSchema } from '@modular/sdk/editor';Members6
- defaultValue
TThe value returned for an out-of-domain input, i.e. `schema(undefined)`.
- getteroptional
SchemaGetterAccessorThe name of the node getter that reads this property's value when the base LexicalNode.exportJSON walks a node's serialization schema. When omitted, the getter name defaults to `get<Prop>` (e.g. `foo` → `getFoo`). Use withAccessors to record a name that doesn't follow that convention (e.g. TextNode's `text` → `getTextContent`), or a SchemaField to read the value straight from a node field. A getter that returns `undefined` omits the property from the exported JSON.
- meta
SerializationSchemaMetaAn introspectable description of this schema's domain.
- setteroptional
SchemaSetterAccessorThe name of the node setter that applies a parsed value of this schema when the base LexicalNode.updateFromJSON walks a node's serialization schema. When omitted, the setter name defaults to `set<Prop>` for the property this schema is bound to in a nodeSchema (e.g. `foo` → `setFoo`). Use withAccessors to record a name that doesn't follow that convention (e.g. TextNode's `text` → `setTextContent`), or a SchemaField to write the value straight to a node field.
- accepts()optional
(value: unknown) => booleanWhether `value` is in this schema's domain, for unionValue deciding which member a value belongs to. A schema is total — it always returns a value — so membership normally has to be inferred from the parse: landing anywhere but the default means the value was recognized. That inference cannot see a value the schema *normalizes into* its own default, which is why a schema that accepts more than its own value type says so directly. This asks about a serialized *input*, not about a parsed value, so it is not a predicate on `T`: a schema that reads more than it writes accepts inputs no `T` ever equals, and a transformValue out of its inner type accepts none of the values it produces. In particular, a combinator may — and numberValue with a `min` deliberately does — decline the very value it defaults to, which is how a union member says "this value is not mine" and lets the union fall through to the member that owns it.
- isEqual()optional
(this: void, a: T, b: T) => booleanWhether two values of this schema's domain say the same thing, for the comparisons that treat a value as absent: compaction dropping a property whose value is the default, and `optional({omitDefault})` / `nullable({defaultAsNull})`. Absent means identity, which is right for the primitive domains but never true of a reference-typed default: arrayValue and objectValue return a fresh value per parse, so without this an array-valued property equal to its default would still be written out. Mirrors `StateValueConfig.isEqual`, which exists for the same reason. Not consulted through a unionValue, which compares structurally because it cannot know which member produced a value. The built-in reference-typed comparators *are* that comparison, so only a custom one from transformValue differs there; see `unionValue` for what it costs. Declared with method syntax deliberately: TypeScript checks a method's parameters bivariantly, which keeps `SerializationSchema<T>` assignable to AnySerializationSchema. A property would make the type invariant in `T` and every `AnySerializationSchema` position would reject it. `this: void` because method syntax otherwise implies a receiver this never has: every caller reads the comparator off the schema and calls it on its own — NodeState equality, `optional({omitDefault})` and the compact export all do — so a comparator written to read `this.meta` type-checked and then threw. Declaring the receiver away says so, and costs nothing: the `this` parameter is not a parameter for bivariance's purposes, so the assignability above is unchanged.