I get the validation message “The value xxx is not valid for yyy”. It happens when I post incorrect value for double type. I have no idea how to change it.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Unfortunately this isn’t something that FluentValidation has the ability to override – the extensibility model for MVC’s validation is somewhat limited in many places, and I’ve not been able to find a way to override this particular message.
An alternative approach you could use is to define two properties on your view model – one as a string, and one as a nullable double. You would use the string property for MVC binding purposes, and the double property would perform a conversion (if it can). You can then use this for validation: