mirror of
https://github.com/alexhopeoconnor/dnsmasq-webui.git
synced 2026-10-21 13:22:35 +10:00
Reorganise codebase: EffectiveConfig, parsers, tests; move tooltips to Metadata
Infrastructure: - Parsers under Serialization/Parsers: Dnsmasq, DnsmasqConfig, EffectiveConfig - EffectiveConfig: Abstractions, Metadata (keys, views, field builder, tooltips, placeholders, write semantics), Rendering, Editing, Validation/Handlers, Readonly - Helpers/Config: only DnsmasqFileEncoding; DnsmasqOptionTooltips moved to Metadata - Remove empty Infrastructure/Parsers and Helpers/Dnsmasq Tests: - Mirror main project: Serialization/Parsers (Dnsmasq, DnsmasqConfig), Services/Dnsmasq/Config, Services/EffectiveConfig, Models, Helpers (TestDataHelper) - Namespaces updated; usings for TestDataHelper and Metadata where needed Docs: README codebase overview and test layout updated.
This commit is contained in:
+63
@@ -0,0 +1,63 @@
|
||||
using DnsmasqWebUI.Models.Dnsmasq.EffectiveConfig;
|
||||
|
||||
namespace DnsmasqWebUI.Infrastructure.Services.EffectiveConfig.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Shared validation kinds for effective-config options.
|
||||
/// Describes the generic value shape; option-specific rules live in the semantic validator or handlers.
|
||||
/// </summary>
|
||||
public enum OptionValidationKind
|
||||
{
|
||||
Flag,
|
||||
Int,
|
||||
String,
|
||||
PathFile,
|
||||
PathDirectory,
|
||||
PathFileOrDirectory,
|
||||
IpAddress,
|
||||
HostOrIp,
|
||||
KeyOnlyOrValue,
|
||||
InversePair,
|
||||
Complex
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether a path value must exist (file/dir) or only its parent, for validation.
|
||||
/// </summary>
|
||||
public enum PathExistencePolicy
|
||||
{
|
||||
None,
|
||||
MustExist,
|
||||
ParentMustExist
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reusable validation metadata for an option: validation kind, path policy, severity, and empty handling.
|
||||
/// </summary>
|
||||
public sealed record OptionValidationSemantics
|
||||
{
|
||||
public OptionValidationKind Kind { get; }
|
||||
public FieldIssueSeverity Severity { get; }
|
||||
public bool AllowEmpty { get; }
|
||||
public PathExistencePolicy? PathPolicy { get; }
|
||||
|
||||
public OptionValidationSemantics(
|
||||
OptionValidationKind kind,
|
||||
FieldIssueSeverity severity = FieldIssueSeverity.Error,
|
||||
bool allowEmpty = true,
|
||||
PathExistencePolicy? pathPolicy = null)
|
||||
{
|
||||
if (pathPolicy is not null && kind is not (
|
||||
OptionValidationKind.PathFile or
|
||||
OptionValidationKind.PathDirectory or
|
||||
OptionValidationKind.PathFileOrDirectory))
|
||||
{
|
||||
throw new ArgumentException("PathPolicy can only be used with path validation kinds.", nameof(pathPolicy));
|
||||
}
|
||||
|
||||
Kind = kind;
|
||||
Severity = severity;
|
||||
AllowEmpty = allowEmpty;
|
||||
PathPolicy = pathPolicy;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user