Using FluentValidation NuGet package, create a custom validator to validate that Master.Children contain one of the names in Master.ValidNames
Example which goes not validate.
internal partial class Program
{
static void Main(string[] args)
{
Master master = new()
{
FamilyName = "Smith",
ValidNames = ["Jim", "Mary", "Karen"],
Children = [new Child { Name = "Mick" }]
};
CustomValidator validator = new();
ValidationResult result = validator.Validate(master);
Console.WriteLine();
if (result.IsValid)
{
...
}
else
{
...
}
}
}