I have a situation where I need to validate that a qty is not over a certain max value. I originally used the common rules MaxValue rule to enforce this behavior. Normally, I would not save my data since IsValid would be false.
But I have a case where I want to increment the qty - save it even if it is invalid - then when I go to fetch my data validate the qty and display the brokenrule if it is invalid.
I tried using a custom rule and set the severity to warning which does allow me to save the data but on fetch the rule is not checked so I see no broken rule for my invalid qty.
Looking for ideas on how to fire the rule on a fetch operation.
The ability to save objects with broken rules (warning/fyi severity settings) has not been rippled throughout the framework.
The suggestion to use "ValidationRules.CheckRules();" after the data fetch will work for editable objects, but NOT for objects derived from ReadOnlyBase.
The concept "I may not be able to change this object, but I want to know what is wrong with it!" is a valid one that the framework does not yet support.
david.wendelken:The ability to save objects with broken rules (warning/fyi severity settings) has not been rippled throughout the framework.
The suggestion to use "ValidationRules.CheckRules();" after the data fetch will work for editable objects, but NOT for objects derived from ReadOnlyBase.
The concept "I may not be able to change this object, but I want to know what is wrong with it!" is a valid one that the framework does not yet support.
It looks like it might be really easy to modify ReadOnlyBase to handle rules to do this.
Think I'll create a ReadOnlyRuledBase and a ReadOnlyRuledListBase class.
Found an answer with some help from a friend.
In my fetch I set the Property, not the internal variable, assigning it the value from the DB. This way the setter for the property gets called which would execute my ValidationRule.CheckRules(). The brokenrule then gets set. MarkOld() is called at the end of setting the values from the DB.
Next, I added a custom rule so that if the rule is broken it is only a warning using Severity.Warning. This made it so IsValid was not set to false when the rule is broken.
It now works as desired, allowing the invalid qty to be set (which is really more a "soft" error), saving the value and then whenever the item is retrieved it sets the brokenrule.
Copyright (c) Marimer LLC