I have sample app in Nancy and have problem with request validation.
I am using FluentValidator with BindAndValidate extension. So for example i have model :
public class User
{
public string Name { get; set; }
public int Age { get; set; }
}
And module with :
Post["/create-user"] = m => this.BindAndValidate<User>());
And there is problem, if client app call module with parameters Name:"foo,Age:"some-string", then Nancy throw exception :
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Exception: some-string is not a valid value for Int32. ---> System.FormatException: Input string was not in a correct format.
Is here any workaround for exception by parameter ("property Age was not in correct format") ?
Thanks