1

Closed

Not able to use Regex for Integer

description

Hi,
I had stuck with the issue in Fluent Validator when I come across a situation where I need to validate the amount entered by user is positive and only accepting 2 digits after decimal point. I had explored and found method .Matches(regex) where it can be applicable for the string types. How can these be applied in the integer types. I had tried with .ToString(), but being the class generated from EF int type does not allowed me to convert to string type to make use of the Regex feature. Can these be resolved?

Thanks,
Dharma
Closed Aug 5, 2013 at 2:58 PM by JeremyS
A regex is a way of processing text, so it can only be applied to a string type.

If you want to use a regex against your user's input, then you will need to define it in your view model as a string, not an integer.

comments