✅ [AllowedValue] not doing anything
Why is my code allowing the name "Jimmy" ?
using System.ComponentModel.DataAnnotations;
public class Foo
{
[AllowedValues(new object [] {"Bill", "Bob"}, "Entered illegal name")]
public string Name { get; set; }
}
class Program
{
public static void Main()
{
Foo f = new()
{
Name = "Jimmy" // works ???
};
}
}using System.ComponentModel.DataAnnotations;
public class Foo
{
[AllowedValues(new object [] {"Bill", "Bob"}, "Entered illegal name")]
public string Name { get; set; }
}
class Program
{
public static void Main()
{
Foo f = new()
{
Name = "Jimmy" // works ???
};
}
}