Field Introspection
Schema instances also expose three read-only introspection helpers:
schema.getFieldDefinitions()returns a frozen snapshot map of the top-level field definitions.schema.getFieldDefinition(path)resolves one field definition by dotted path, including nested object fields and numeric array segments such asroles.0.id, and returns it as a frozen snapshot.schema.getFieldMessages(path)returns the field'smessagesobject as a frozen snapshot, or{}when none exist.
These helpers are intentionally inspection-only. They clone the schema metadata they expose so adapter code can read field settings without gaining a back door to mutate runtime validation behavior.
Example:
javascript
const roleSchema = createSchema({
id: { type: 'string', required: true }
})
const teamSchema = createSchema({
name: { type: 'string', required: true },
roles: {
type: 'array',
items: roleSchema
}
})
const topLevelDefinitions = teamSchema.getFieldDefinitions()
const roleIdDefinition = teamSchema.getFieldDefinition('roles.0.id')
const roleIdMessages = teamSchema.getFieldMessages('roles.0.id')In that example:
topLevelDefinitionscontains snapshots fornameandrolesroleIdDefinitionresolves through the array item schema to the nestedidfieldroleIdMessagesreturns{}because that field did not define amessagesobject
Treat the returned objects as metadata for rendering and adapter logic, not as something to mutate.