UNPKG

@player-ui/player

Version:

36 lines 1.78 kB
import type { BindingInstance } from "../binding"; import type { BatchSetTransaction, DataModelImpl, DataModelOptions, DataModelMiddleware, Updates } from "../data"; import type { Logger } from "../logger"; import type { ValidationResponse } from "./types"; /** * A BindingInstance with an indicator of whether or not it's a strong binding */ export type StrongOrWeakBinding = { /** BindingInstance in question */ binding: BindingInstance; /** Boolean indicating whether the relevant BindingInstance is a strong binding */ isStrong: boolean; }; /** * Returns a validation object if the data is invalid or an set of BindingsInstances if the binding itself is a weak ref of another invalid validation */ export type MiddlewareChecker = (binding: BindingInstance, model: DataModelImpl) => ValidationResponse | Set<StrongOrWeakBinding> | undefined; /** * Middleware for the data-model that caches the results of invalid data */ export declare class ValidationMiddleware implements DataModelMiddleware { validator: MiddlewareChecker; shadowModelPaths: Map<BindingInstance, any>; private logger?; private shouldIncludeInvalid?; constructor(validator: MiddlewareChecker, options?: { /** A logger instance */ logger?: Logger; /** Optional function to include data staged in shadowModel */ shouldIncludeInvalid?: (options?: DataModelOptions) => boolean; }); set(transaction: BatchSetTransaction, options?: DataModelOptions, next?: DataModelImpl): Updates; get(binding: BindingInstance, options?: DataModelOptions, next?: DataModelImpl): any; delete(binding: BindingInstance, options?: DataModelOptions, next?: DataModelImpl): void | undefined; } //# sourceMappingURL=validation-middleware.d.ts.map