I am wondering is there a way to implement Error Message when there are more than two decimal places?
e.g., 50.678 throw error message or 126.96.36.199 throw error message
Please let me know if there is a way to acheieve this functionality in CSLA.
For now i am using regular expressions, but i would like to implement this in CSLA.
You won't be able to use one of the seeded business rules. You would have to create a custom business rule to handle this. In your first case of 50.678, you could use a round to round it to 2 decimals, then compare that value with the original. If they are different, you know you have more than 2 decimal places. I'm a little confused with your second example of 188.8.131.52 Is this field a string or number? What values are valid? Can they have more than one decimal point and it still be valid?
I understood, but I am missing the formatting logic.
private static bool IntegerValidation<T>(T target, RuleArgs e) where T : ClassName
if (target.ReadProperty(txtbox1proprty) != null &&.........
e.Description = "Do not allow decimals";
Sorry, I had just edited my above comment. It has a little more detail, but what exactly are you trying to accomplish? By the name IntegerValidation, I assume you are determining if this is an integer, which is not what you specified to begin with. Normally when dealing with numbers and not allowing users to enter non-numeric data, I do it at the control level instead of the rule level. i.e. I will use a third party numeric map textbox or there are also examples out on the internet on customizing the native textbox to only allow a valid number.
Copyright (c) Marimer LLC