Type Alias: SchemaMode
SchemaMode =
"strict"|"default"|"autoschema"
Defined in: src/Mnemonic/types.ts:232
Controls how the provider enforces versioned schemas on stored values.
-
"default"— Schemas are optional. When a schema exists for the stored version it is used for validation; otherwise the hook'scodecoption is used directly with no validation. This is the recommended starting mode. -
"strict"— Every read and write must have a registered schema for the stored version. If no matching schema is found the value falls back todefaultValuewith aSchemaError(SCHEMA_NOT_FOUNDon reads,WRITE_SCHEMA_REQUIREDon writes). When no schemas are registered and no explicit schema is provided, writes fall back to a codec-encoded (v0) envelope. -
"autoschema"— Like"default", but when a key has no schema registered at all, the library infers a JSON Schema at version 1 from the first successfully decoded value and registers it viaSchemaRegistry.registerSchema. Subsequent reads/writes for that key then behave as if the schema had been registered manually.
Remarks
In "default" and "strict" modes, registry lookups are cached under the
assumption that the schema registry is immutable for the lifetime of the
provider. If you need to update schemas, publish a new app version and
remount the provider. "autoschema" does not assume immutability.
Default
"default"
See
- SchemaRegistry - Registry that stores schemas and migrations
- KeySchema - Individual schema definition