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

Prompt.Bind support for IntegerValidator (MinValue, MaxValue), DefaultValue attributes #281

Open
abrasat opened this issue Jun 13, 2024 · 2 comments

Comments

@abrasat
Copy link

abrasat commented Jun 13, 2024

Does Prompt.Bind support also the IntegerValidator (MinValue, MaxValue), DefaultValue attributes in the model?
I tried this :

public class MyModel
{
    [Display(Name = "MyParam")]
    [IntegerValidator(MinValue = 1, MaxValue = 3)]
    [DefaultValue(2)]
    [Required]
    public int MyParam { get; set; }
}
...
var myModel = Prompt.Bind<MyModel>();

but see (0) as default, and can also enter any integer value.

@shibayan
Copy link
Owner

I think the following definition achieves the same thing.

public class MyModel
{
    [Display(Name = "MyParam")]
    [Range(1, 3)]
    [Required]
    public int MyParam { get; set; } = 2;
}

@abrasat
Copy link
Author

abrasat commented Jun 17, 2024

You are right, it works. Thanks!
Where can I find the list with the supported annotations?

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

2 participants