In our application, we have a number of validations that are warnings. In our minds, we think of warning as "something to tell the user about but not something that should stop them from saving." I think that roughly follows the idea of a warning verifier result but we've noticed a problem. As the user is enter data, the warnings correctly show up. But then when they go to save, the warnings go away. Perhaps it's a configuration on our end but I'm not entirely sure.
We use the TreatWarningsAsErrors option on all our verifiers. We do this because:
- We want the warnings to show up in the UI (get fired via INotifyDataErrorInfo)
- We want the entities to keep track of warnings in their EntityAspect.ValidationErrors collection
When saving, we use the default SaveOptions.IgnoreClientValidationErrors of true. We don't want the warnings to stop the save. We do, however, have logic that checks to make sure there aren't any true errors on any of the entities....if so, we stop the save process before it even reaches the point of calling EntityManager.SaveChangesAsync.
I noticed that when IgnoreClientValidationsErrors is set to true, it will clear out all the validation "errors" (including warnings) for all the entities. That seems to be the part that is messing us up. When the entities go into the SaveChangesAsync, they have lots of important warnings. But after the save, the warnings got cleared.
Also, some of our warnings are complicated/expensive....so we can't just re-validate everything after the save to get the warnings added back in. Or at least.....we really, really don't want to have to do that. I suppose it might be possible if that is the only way.
Is there something that we are missing here? It seems like our combination of TreatWarningsAsErrors = true and IgnoreClientValidationErrors = true are somewhat working against each other.