mirror of
https://github.com/alexhopeoconnor/dnsmasq-webui.git
synced 2026-10-16 10:41:34 +10:00
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.
64 lines
1.7 KiB
C#
64 lines
1.7 KiB
C#
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;
|
|
}
|
|
}
|