Class ValidationSession
- Namespace
- The.Entities.Validation
- Assembly
- Instagile.dll
Live validation for an edit surface: maintains a current ValidationReport for the graph rooted at an entity, re-running synchronous checks whenever the loaded graph changes and asynchronous checks on a trailing debounce. UI layers subscribe to ReportChanged and decide which findings to display and when; the session holds no display policy.
public sealed class ValidationSession : IDisposable
- Inheritance
-
ValidationSession
- Implements
- Inherited Members
Constructors
ValidationSession(IEntity, ValidationIntent?, TimeSpan?, RelationshipInfo?)
public ValidationSession(IEntity root, ValidationIntent? intent = null, TimeSpan? asyncDelay = null, RelationshipInfo? excluding = null)
Parameters
rootIEntityintentValidationIntent?asyncDelayTimeSpan?excludingRelationshipInfo
Properties
Attempted
True once a gated command has requested validation via MarkAttempted(). Display policies typically reveal all findings once an attempt has been made.
public bool Attempted { get; }
Property Value
Intent
The intent the session's live refreshes evaluate and Report displays: the default Save until a gated command runs with an explicit intent, which the session then keeps so the user can address that command's findings. The displayed intent never widens another command's gate: RunAsync(ValidationIntent?, CancellationToken?) blocks each caller on its own intent's report.
public ValidationIntent Intent { get; }
Property Value
LocalFindings
Findings contributed by UI components about state the rules cannot see - text that cannot be parsed into the bound property, a failed upload. They are not part of Report and no display policy applies: the contributing component displays its own findings immediately. Command gates consult them alongside the report, so an error-level local finding blocks commands the same way a rule finding does.
public IReadOnlyList<ValidationFinding> LocalFindings { get; }
Property Value
Report
The current report: synchronous findings from the latest refresh plus the latest completed asynchronous findings.
public ValidationReport Report { get; }
Property Value
Root
The entity whose owned graph this session validates.
public IEntity Root { get; }
Property Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
MarkAttempted()
Records that a gated command has requested validation, so display policies can reveal every finding.
public void MarkAttempted()
Refresh()
Re-evaluates the synchronous checks over the loaded graph immediately, and schedules the asynchronous checks to run after a quiet period. Called automatically when a property in the graph changes.
public void Refresh()
RunAsync(ValidationIntent?, CancellationToken?)
Runs a complete validation now - loading the owned graph and awaiting the asynchronous checks - and returns the report for the given intent (default Save). Commands call this before acting on validity, and each blocks on its own intent's report: a sticky intent adopted earlier never blocks a later command. Passing an intent also re-intents the session, so subsequent live refreshes keep evaluating that intent's rules while the user addresses the findings; passing null leaves the displayed intent unchanged.
public Task<ValidationReport> RunAsync(ValidationIntent? intent = null, CancellationToken? cancellationToken = null)
Parameters
intentValidationIntent?cancellationTokenCancellationToken?
Returns
SetLocalFindings(object, IReadOnlyList<ValidationFinding>)
Replaces the local findings contributed by the given component; an empty list withdraws its contribution. Contributors withdraw when they leave the UI, so that stale findings cannot block commands.
public void SetLocalFindings(object contributor, IReadOnlyList<ValidationFinding> findings)
Parameters
contributorobjectfindingsIReadOnlyList<ValidationFinding>
Events
ReportChanged
Raised when the session's validation state has changed - the Report was replaced, LocalFindings changed, or the session was marked attempted - on the synchronization context the session was created on.
public event Action? ReportChanged