StoreValidationFailure
See source codeTable of contents
Information about a record validation failure that occurred in the store.
This interface provides context about validation errors, including the failed record, the store state, and the operation phase where the failure occurred. It's used by validation failure handlers to implement recovery strategies.
interface StoreValidationFailure<R extends UnknownRecord> {}
Example
const schema = StoreSchema.create(
{ book: Book },
{
onValidationFailure: (failure: StoreValidationFailure<Book>) => {
console.error(`Validation failed during ${failure.phase}:`, failure.error)
console.log('Failed record:', failure.record)
console.log('Previous record:', failure.recordBefore)
// Return a corrected version of the record
return { ...failure.record, title: failure.record.title || 'Untitled' }
},
}
)
Properties
error
error: unknown
phase
phase: 'createRecord' | 'initialize' | 'tests' | 'updateRecord'
record
record: R
recordBefore
recordBefore: null | R
store
store: Store<R>
Prev
StoreSnapshotNext
StoreValidator