Today, I delivered a session at Techorama, a new (and good – congrats to Gill, Kevin, Pieter and everyone who made this happen!) Belgian conference. The session was about validation & business rules for Windows Store apps.
LOB applications for Windows tablets are slowly but surely becoming more prevalent – but there’s one big gaping hole: business apps require validation and business rules, and those rules are often way more complicated than what you can handle with data annotations. And, regardless of that, there’s really very little support for validation in Windows Store apps. If you’re used to, say, WPF, you’re used to binding properties like ValidatesOnExceptions, ValidatesOnDataErrorInfoChanged, … which tie in nicely with the UI. Not so in Windows Store apps, not even when you use data annotations.
So validation for LOB Windows Store apps is a 3-part story: you need a component/engine that allows you to define complex business rules, and that component must be available on both client and server. You need a way to get your property setters to nicely interact with that business rule component. And you need a way to visualize those errors.
So, rather than explaining how to write a MinLength, RegEx, async, … validator, I wanted to take another approach: the session was aimed at building a business rule engine that ties in nicely with Windows Store apps.
I promised everyone the code & slidedeck, so: here it is! 🙂 I hope you enjoy it!
PS: @M3rken (jokingly, I think ;-)) asked me if I would publish this as a NuGet package. I’m not going to do that, for one simple reason: what I showed in the session was a skeleton component that still requires *a lot* of work & extensions before I would call it a true “business rule engine” – the code should be considered as something to start building from, not something to use in a production environment. For that, it should include way more validation options, should take property chains into account, handle expressions in RuleBuilder extensions, allow conditional rules, allow multiple RuleSets, inheritance, influencing properties, more support for data binding types in the behavior, more actions, etc, etc. So, in short, I don’t think it’s good enough to qualify as a useful NuGet package. But regardless of that, it was very nice to read that question. 🙂
Oh, and if you need more info on such a component, I’m working on a thing or two, so drop me a line 😉