Introduce EnsureProperties to validate required property names against the Columns dictionary, throwing an exception if any are missing. This helps enforce configuration completeness.
14 lines
509 B
C#
14 lines
509 B
C#
namespace ReC.Infrastructure.Options.Shared;
|
|
|
|
public record EntityBaseOptions()
|
|
{
|
|
public Dictionary<string, string> Columns { get; init; } = [];
|
|
|
|
public void EnsureProperties(IEnumerable<string> propertyNames)
|
|
{
|
|
var missingProperties = propertyNames.Except(Columns.Select(col => col.Key)).ToList();
|
|
|
|
if (missingProperties.Count != 0)
|
|
throw new InvalidOperationException($"The following properties are not configured: {string.Join(", ", missingProperties)}");
|
|
}
|
|
} |