September 2010 Blog Posts

RIA Services Validation: Attribute Propagation

Since the beginning of the RIA Services project, a primary tenet was to propagate validation rules defined on the server up to the client, integrating the validation directly into the Silverlight UI.  This came to fruition with RIA Services v1.0 and you can in fact apply an attribute to your model on the server and automatically get instant client-side validation of data entry on even the simplest of Textbox controls.  In fact, some validation rules are inferred from your data model directly.  This is a feat that many other frameworks have attempted to accomplish, but I believe RIA Services has...

posted @ Thursday, September 30, 2010 2:37 AM | Feedback (2)

RIA Services Validation: Custom Reusable Validators

We just covered Custom Validation Methods, where we learned how to use CustomValidationAttribute to invoke a static (VB: Shared) method to perform validation.  Let’s talk about an alternate approach to custom validation though: creating custom, reusable validators by deriving from ValidationAttribute.  While it’s true that the custom validation methods used by [CustomValidation] could certainly be reusable, I tend to think of that approach as a light-weight way to call specific business logic routines for validation.  The approach we’re about to see is what I use when I’m creating an inventory of validators to be reused throughout my project(s). Deriving...

posted @ Sunday, September 26, 2010 3:39 AM | Feedback (7)

RIA Services Validation: Custom Validation Methods

In our last installment, we learned about the standard validators that ship in the System.ComponentModel.DataAnnotations assembly.  RequiredAttribute, RangeAttribute, StringLengthAttribute, and RegularExpressionAttribute all derive from ValidationAttribute and cover many common validation scenarios.  Every system has its own business rules though, and therefore it’s imperative that RIA Services allows you to create custom validators to implement your own logic.  Moreover, your custom error messages must plug into the same framework that powers the standard validators.  To address this requirement, we added CustomValidationAttribute. Using CustomValidationAttribute to Invoke a Method System.ComponentModel.DataAnnotations.CustomValidationAttribute allows you to easily redirect a validator to a method you’ve...

posted @ Saturday, September 25, 2010 11:12 PM | Feedback (2)

RIA Services Validation: Standard Validators

RIA Services offers powerful features for flowing validation from your entity model all the way up to the Silverlight UI.  In fact, flowing your validation rules from the server into your form controls was one of the primary tenets of RIA Services V1, and our team did the work of getting validation integrated deeply into Silverlight, long before RIA Services was released.  In this post we’ll take a look at the standard validators that are offered. System.ComponentModel.DataAnnotations.ValidationAttribute RIA Services employs the ValidationAttribute class from System.ComponentModel.DataAnnotations for defining validation rules on your entity model.  ValidationAttribute itself is abstract (VB:...

posted @ Wednesday, September 22, 2010 3:16 AM | Feedback (4)