mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-05 03:29:40 +00:00
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Sync Flatpak repo (push) Blocked by required conditions
Build and Release / Collect Flatpak artifacts (push) Blocked by required conditions
Build and Release / Verify (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
43 lines
2.1 KiB
C#
43 lines
2.1 KiB
C#
using MudBlazor.Interfaces;
|
|
|
|
namespace AIStudio.Tools.Validation;
|
|
|
|
/// <summary>
|
|
/// Gives form fields a fresh verdict when a field they are checked against changes.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// A MudForm checks a field only when that very field changes. Where the rule of one field reads
|
|
/// another one -- the required confidence level is checked against the embedding provider, and so
|
|
/// are the token limits -- changing the other field leaves the verdict as it was, and an error which
|
|
/// no longer holds stays on screen. Hooked to the FieldChanged event of the form, this checks the
|
|
/// dependent fields again after every change. A state which is no field of the form, such as
|
|
/// showing the expert settings, passes no changed field at all.
|
|
/// </remarks>
|
|
public static class DependentFieldValidation
|
|
{
|
|
/// <summary>
|
|
/// Validates the dependent fields anew.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// The field which just changed is skipped, because the form checks it anyway. So is every
|
|
/// field the user has not reached yet and which shows no error: a dialog just opened must not
|
|
/// greet anybody with errors about fields they have not filled in.
|
|
/// <br/><br/>
|
|
/// A field checks the value it holds itself, and a value set in code reaches it only with the
|
|
/// next render. Where the code changes a value before asking for a fresh verdict, it asks after
|
|
/// that render, i.e., in OnAfterRenderAsync; asked at once, the field would judge the old value.
|
|
/// </remarks>
|
|
/// <param name="changedField">The field the form reported as changed, or null when the change happened outside the fields.</param>
|
|
/// <param name="dependentFields">The fields whose rules read other fields. A field which is not rendered yet is null.</param>
|
|
public static async Task RevalidateAsync(IFormComponent? changedField, params IFormComponent?[] dependentFields)
|
|
{
|
|
foreach (var field in dependentFields)
|
|
{
|
|
if (field is null || ReferenceEquals(field, changedField))
|
|
continue;
|
|
|
|
if (field.Touched || field.HasErrors)
|
|
await field.Validate();
|
|
}
|
|
}
|
|
} |