Error Level 'Warn' does not work as expected

Apr 14, 2010 at 11:57 AM

The error level 'Warn' does not work as expected in my opinion. When x.Warn(...) is used instead of x.Check(...) I expect the Object to be considered valid (IsValid=true) even if warnings are created.

I checked the source code and the level is set as a property in the PropertyValidator.  However, this property is never accessed later on and generated warnings and errors are both stored as ValidationResult in the same list 'Errors' in the ValidationNotification. Because the level-Property is not available from ValidationResult it is also not possible to find out why an item was added to the Errors-list. (was it added as a warning or as an error?)

Is it possible to have two lists 'Errors' and 'Warnings' (-> a third level 'Info' comes into mind as well - see below) instead of only one combining the two levels in one? Or to have at least the level-property available in ValidationResult for later filtering.

Levels:

Errors: If a validation error is detected the validated object is considered invalid (e.g. an empty password')

Warnings: If a validation warning is detected the validated object is considered valid (e.g. a weak password below a certain 'security threshold')

Info: An info is generated for convenience (e.g. a medium strong password)

As far as i can tell the warning level - feature is not implemented yet. Is this correct?

 

kind regards,

alain

 

 

Coordinator
Apr 14, 2010 at 8:02 PM

Alain,

Thanks for the observation around the Error Level. You are correct that it wasn't on the ValidationResult or being taken into account by the ValidationNotification.IsValid.

I just committed a change that should add this functionality. I didn't implement two lists (ie one for Warn, and another for Error). I felt it would be pretty straightforward to write a LINQ expression to filter the list. Feel free to grab the checkout the code from the trunk. I look forward to any further feedback or questions you might have about the Error Level functionality or anything else regarding SpecExpress.

Apr 15, 2010 at 9:02 AM

Thank you,

the latest changes seem to fix this issue. thank you for the quick response

Alain