Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class Style - Add EnumDataType Attribute on Enum to Allow ValidationContext #4882

Open
QzLP2P opened this issue May 7, 2024 · 0 comments
Open

Comments

@QzLP2P
Copy link

QzLP2P commented May 7, 2024

I need to validate that enum is defined.
Can you add support for EnumDataType

Exemple below :

   [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
    public enum BeerType
    {

        [System.Runtime.Serialization.EnumMember(Value = @"Aromatique")]
        Aromatique = 0,

        [System.Runtime.Serialization.EnumMember(Value = @"Doux")]
        Doux = 1,

        [System.Runtime.Serialization.EnumMember(Value = @"Ambre")]
        Ambre = 2,
        // ...
    }

    [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
    public partial class SetBeerInput
    {

        [System.Text.Json.Serialization.JsonPropertyName("type")]
        [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
        [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))]
        // TODO : Add  [EnumDataType(typeof(BeerType))] To Allow ValidationContext
        public BeerType Type { get; set; } = default!;

        [System.Text.Json.Serialization.JsonPropertyName("name")]
        [System.ComponentModel.DataAnnotations.Required]
        [System.ComponentModel.DataAnnotations.StringLength(30, MinimumLength = 7)]
        public string Name { get; set; } = default!;

    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant