-
Notifications
You must be signed in to change notification settings - Fork 8
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
Validators not applied to parameters with BindingSource = Form #7
Comments
Hi @steverb38, I don't think there is a specific reason for not having validation on [FromForm] parameters other than that I never needed it in my personal projects (from which this library sprouted). I'm currently thinking about introducing configuration options for the BindingSources. Could you provide me with some examples where you would need validation on [FromForm] parameters? |
Hi, My use-case was submitting a form for a file upload to the server, along with some associated parameters to control the behaviour of the API in processing the uploaded file. The API action method looks something like: [HttpPost]
public async Task<ActionResult<MyResponse>> Post([FromForm] MyRequest request)
{
...
} where MyRequest is like: public class MyRequest
{
public IFormFile File { get; set; }
public string Param1 { get; set; }
public bool Param2 { get; set; }
....
} There were then some validations to perform on the Param1, Param2,... values to ensure together they made sense. Steve. |
@steverb38 that's great to hear! I actually have been playing with the idea to expose the binding sources via the options builder and via the data annotations attributes to make it all configurable. The default would be |
Opened a PR for it: https://github.com/SharpGrip/FluentValidation.AutoValidation/pull/8/files. Would appreciate it if you could take a look at it :). |
Hi. Fantastic! I'll take a look later today. 👍 |
Hi @steverb38, I just released v1.2.0 which includes the configurable binding sources. |
Hi,
Thanks for providing this package for auto FluentValidation!
My first attempt as using this was trying to apply a Validator to a Form parameter but I see the code specifically only applies validators to Body or Query parameters. Not being a web developer particularly, is there a specific reason for this restriction?
More a question in education (for me) perhaps?
Steve.
The text was updated successfully, but these errors were encountered: