AllowedValuesAttribute Class
A validation attribute that restricts a string (or string-collection) value to a fixed set, matched exactly.
An absent value passes: whether a member is required is a separate question, asked by a separate attribute,
which is why the framework's own AllowedValues cannot stand in for this one - it refuses null.
Shared by the MVC and Minimal API OIDC server adapters, whose source generators emit it onto a generated model
whenever the corresponding core property carries the declarative AllowedValues marker.
public class AllowedValuesAttribute : System.ComponentModel.DataAnnotations.ValidationAttributeInheritance System.Object → System.Attribute → System.ComponentModel.DataAnnotations.ValidationAttribute → AllowedValuesAttribute
Constructors
AllowedValuesAttribute(string[]) Constructor
A validation attribute that restricts a string (or string-collection) value to a fixed set, matched exactly.
An absent value passes: whether a member is required is a separate question, asked by a separate attribute,
which is why the framework's own AllowedValues cannot stand in for this one - it refuses null.
Shared by the MVC and Minimal API OIDC server adapters, whose source generators emit it onto a generated model
whenever the corresponding core property carries the declarative AllowedValues marker.
public AllowedValuesAttribute(params string[] allowedValues);Parameters
allowedValues System.String[]