RE: RIA Domain Services and required dependencies
I have my own button on the form that calls dataForm.ValidateItem(). It works for Required and Range validators, but doesn't seem to fire the Custom validators. ValidateItem() basically returns true and I end up with an exception that shouldn't happen when I SubmitChanges(). Is this a known issue? T. From: ozsilverlight-boun...@ozsilverlight.com [mailto:ozsilverlight-boun...@ozsilverlight.com] On Behalf Of Miguel Madero Sent: Wednesday, 27 January 2010 1:24 PM To: ozSilverlight Subject: Re: RIA Domain Services and required dependencies You need a custom validator. http://blogs.microsoft.co.il/blogs/bursteg/archive/2009/04/14/net-ria-servic es-custom-validation.aspx -- Miguel A. Madero Reyes www.miguelmadero.com (blog) m...@miguelmadero.com ___ ozsilverlight mailing list ozsilverlight@ozsilverlight.com http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight
Re: RIA Domain Services and required dependencies
Hi Miguel, I ran the code: var ctx = new ValidationContext(dfTermItem.CurrentItem, null, null) { MemberName = TermCategoryID }; var validationResults = new CollectionValidationResult(); //validate against a guid that should fail if (Validator.TryValidateProperty(new Guid(---0022-0002), ctx, validationResults)) { Debug.WriteLine(Success); } else { Debug.WriteLine(Fail); } It always returns Success and unfortunately, it didn't fire the Custom Validator at all. dfTermItem.CurrentItem is of type Term Term has a property TermCategoryID In the metadata.cs file, TermCategoryID is declared as follows: [CustomValidation(typeof (TermCustomValidation),EnsureTermCategory,ErrorMessageResourceName = TTermCategoryRequiredError, ErrorMessageResourceType = typeof (ValidationErrorResources))] [Bindable(true, BindingDirection.TwoWay)] public Guid TermCategoryID; TermCustomValidation is a static class: public static class TermCustomValidation { public static ValidationResult EnsureTermCategory(Guid TermCategoryID, ValidationContext validationContext) { Term currentTerm = validationContext.ObjectInstance as Term; if (currentTerm != null) { if (currentTerm.TermCategoryID == Guid.Empty) { return new ValidationResult(Term Type is a required field.); } //fyi, EnumHelper.GetID simply returns a guid from an attribute attached to an enum value if (currentTerm.TermCategoryID==EnumHelper.GetID(TermCategoryList.Vendor)) { if (currentTerm.VendorID == null || currentTerm.VendorID == Guid.Empty) { return new ValidationResult(Vendor is required when a Vendor Term Type is selected.); } } else if (currentTerm.TermCategoryID == EnumHelper.GetID(TermCategoryList.Model)) { if (currentTerm.ModelID == null || currentTerm.ModelID == Guid.Empty) { return new ValidationResult(Vendor, Brand and Model are required when a Model Term Type is selected.); } } } return ValidationResult.Success; } Note that it never actually debugs into the EnsureTermCategory method. I would have thought it would have returned Failed! Regards, Tony From: ozsilverlight-boun...@ozsilverlight.com [mailto:ozsilverlight-boun...@ozsilverlight.com] On Behalf Of Miguel Madero Sent: Thursday, 28 January 2010 11:10 AM To: ozSilverlight Subject: Re: RIA Domain Services and required dependencies I've not experienced that issue. Try to explicitly validate the property to see if that's an issue with the DataForm or just with how you set up the validation. var ctx = new ValidationContext(this, null, null) { MemberName = NameOfYourPropertyGoesHere }; var validationResults = new CollectionValidationResult(); if (Validator.TryValidateProperty(yourNewValueGoesHere, ctx, validationResults)) // It was valid else // it wasn't valid, check the validationResults for details Could you also try it with the example on the link I sent? -- Miguel A. Madero Reyes www.miguelmadero.com (blog) m...@miguelmadero.com ___ ozsilverlight mailing list ozsilverlight@ozsilverlight.com http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight
Re: Real time updates to and from clients
Are duplex wcf services not available in silverlight? On Thu, 28 Jan 2010 08:59:33 +0530 wrote gt;Hi All, gt;I play around with real time updates to and from SL clients, and have figured out a couple of possibilities with Silverlight.SocketsPolling over WCF in SL2 or SL3 (HTTP)WCF net.tcp protocol in Silverlight 4 (Polling over TCP Sockets)Anyone has some good or bad experience with them? gt;Regardingnbsp;PerformanceEase of developmentSecurity (Firewalls are not a problem)nbsp; gt;My opinion so far:Socketsnbsp;Harder to write than calling a WCF serviceBest option regarding performancePolling over WCF (HTTP)Not a nice solution regarding performanceWCF net.tcp protocol in Silverlight 4 (Polling over TCP Sockets)Under the hood sockets, but I don't have to worry about socketsGood performancePort restrictions to all of those I have seen... gt;Your opinions? gt;PSThis guy has a nice Socket implementation for getting updates from a serverhttp://petermcg.wordpress.com/2008/06/05/stock-list-demo-part-3/ nbsp; gt;This guy is writing about WCF net.tcp in SL 4http://tomasz.janczuk.org/2009/11/wcf-nettcp-protocol-in-silverlight-4.htmlnbsp; gt;PS2What can I do against port restrictions? gt;.peter.gfader.http://peitor.blogspot.com/nbsp; gt; gt; gt;nbsp;___ gt;ozsilverlight mailing list gt;ozsilverlight@ozsilverlight.com gt;http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight gt;___ ozsilverlight mailing list ozsilverlight@ozsilverlight.com http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight
Re: Re: Real time updates to and from clients
Silly comment.nbsp; Of course not, as this would require tcp. On Thu, 28 Jan 2010 10:08:32 +0530 wrote gt; Are duplex wcf services not available in silverlight? gt; gt;On Thu, 28 Jan 2010 08:59:33 +0530 wrote gt;gt;Hi All, gt;gt;I play around with real time updates to and from SL clients, and have figured out a couple of possibilities with Silverlight.SocketsPolling over WCF in SL2 or SL3 (HTTP)WCF net.tcp protocol in Silverlight 4 (Polling over TCP Sockets)Anyone has some good or bad experience with them? gt;gt;RegardingPerformanceEase of developmentSecurity (Firewalls are not a problem) gt;gt;My opinion so far:SocketsHarder to write than calling a WCF serviceBest option regarding performancePolling over WCF (HTTP)Not a nice solution regarding performanceWCF net.tcp protocol in Silverlight 4 (Polling over TCP Sockets)Under the hood sockets, but I don't have to worry about socketsGood performancePort restrictions to all of those I have seen... gt;gt;Your opinions? gt;gt;PSThis guy has a nice Socket implementation for getting updates from a serverhttp://petermcg.wordpress.com/2008/06/05/stock-list-demo-part-3/ gt;gt;This guy is writing about WCF net.tcp in SL 4http://tomasz.janczuk.org/2009/11/wcf-nettcp-protocol-in-silverlight-4.html gt;gt;PS2What can I do against port restrictions? gt;gt;.peter.gfader.http://peitor.blogspot.com/ gt;gt; gt;gt; gt;gt;___ gt;gt;ozsilverlight mailing list gt;gt;ozsilverlight@ozsilverlight.com gt;gt;http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight gt;gt; gt;___ gt;ozsilverlight mailing list gt;ozsilverlight@ozsilverlight.com gt;http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight gt;___ ozsilverlight mailing list ozsilverlight@ozsilverlight.com http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight
RE: Real time updates to and from clients
Peter, We used sockets in Silverlight2 to prototype a spatial collaboration concept. The main issues we faced were: 1. Needed to run a windows application (testing=console app, production=windows service) for both server side processing and also as a policy service. Made it hard to deploy. 2. Very raw technology, we had to deal with packets of data and worried about robustness of the server solution under heavy load. In the end we didn't move beyond the prototype but decided we need to evaluate the purchase of a socket based communication server (often used for online games). In Silverlight 3 didn't they introduce a duplex WCF service? John. From: ozsilverlight-boun...@ozsilverlight.com [mailto:ozsilverlight-boun...@ozsilverlight.com] On Behalf Of Peter Gfader Sent: Thursday, 28 January 2010 1:33 PM To: ozsilverlight@ozsilverlight.com Subject: Real time updates to and from clients Hi All, I play around with real time updates to and from SL clients, and have figured out a couple of possibilities with Silverlight. 1. Sockets 2. Polling over WCF in SL2 or SL3 (HTTP) 3. WCF net.tcp protocol in Silverlight 4 (Polling over TCP Sockets) Anyone has some good or bad experience with them? Regarding 1. Performance 2. Ease of development 3. Security (Firewalls are not a problem) My opinion so far: 1. Sockets 1. Harder to write than calling a WCF service 2. Best option regarding performance 2. Polling over WCF (HTTP) 1. Not a nice solution regarding performance 3. WCF net.tcp protocol in Silverlight 4 (Polling over TCP Sockets) 1. Under the hood sockets, but I don't have to worry about sockets 2. Good performance Port restrictions to all of those I have seen... Your opinions? PS This guy has a nice Socket implementation for getting updates from a server http://petermcg.wordpress.com/2008/06/05/stock-list-demo-part-3/ This guy is writing about WCF net.tcp in SL 4 http://tomasz.janczuk.org/2009/11/wcf-nettcp-protocol-in-silverlight-4.html PS2 What can I do against port restrictions? .peter.gfader. http://peitor.blogspot.com/ ___ ozsilverlight mailing list ozsilverlight@ozsilverlight.com http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight
Re: RIA Domain Services and required dependencies
I just reflected over the code and found that it was using some reflection to retrieve the custom attributes. So I added in this code to see if the attributes were, in fact, visible. foreach (PropertyInfo info in typeof(Term).GetProperties()) { foreach (Attribute attribute in info.GetCustomAttributes(true).CastAttribute()) { Debug.WriteLine(attribute); } } And the answer is that it can see all the normal attributes, such as RequiredAttribute, DisplayAttribute, etc, but NOT the CustomValidationAttribute. Note that I have done a clean before building. I don't know why it's not recognising the CustomValidation attribute. Perhaps it is something to do with the meta data needing to map the particular attribute to the original class? T. On Thu, Jan 28th, 2010 at 3:32 PM, ton...@tpg.com.au wrote: Hi Miguel, I ran the code: var ctx = new ValidationContext(dfTermItem.CurrentItem, null, null) { MemberName = TermCategoryID }; var validationResults = new CollectionValidationResult(); //validate against a guid that should fail if (Validator.TryValidateProperty(new Guid(---0022-0002), ctx, validationResults)) { Debug.WriteLine(Success); } else { Debug.WriteLine(Fail); } It always returns Success and unfortunately, it didn't fire the Custom Validator at all. dfTermItem.CurrentItem is of type Term Term has a property TermCategoryID In the metadata.cs file, TermCategoryID is declared as follows: [CustomValidation(typeof (TermCustomValidation),EnsureTermCategory,ErrorMessageResourceName = TTermCategoryRequiredError, ErrorMessageResourceType = typeof (ValidationErrorResources))] [Bindable(true, BindingDirection.TwoWay)] public Guid TermCategoryID; TermCustomValidation is a static class: public static class TermCustomValidation { public static ValidationResult EnsureTermCategory(Guid TermCategoryID, ValidationContext validationContext) { Term currentTerm = validationContext.ObjectInstance as Term; if (currentTerm != null) { if (currentTerm.TermCategoryID == Guid.Empty) { return new ValidationResult(Term Type is a required field.); } //fyi, EnumHelper.GetID simply returns a guid from an attribute attached to an enum value if (currentTerm.TermCategoryID==EnumHelper.GetID(TermCategoryList.Vendor)) { if (currentTerm.VendorID == null || currentTerm.VendorID == Guid.Empty) { return new ValidationResult(Vendor is required when a Vendor Term Type is selected.); } } else if (currentTerm.TermCategoryID == EnumHelper.GetID(TermCategoryList.Model)) { if (currentTerm.ModelID == null || currentTerm.ModelID == Guid.Empty) { return new ValidationResult(Vendor, Brand and Model are required when a Model Term Type is selected.); } } } return ValidationResult.Success; } Note that it never actually debugs into the EnsureTermCategory method. I would have thought it would have returned Failed! Regards, Tony From: ozsilverlight-boun...@ozsilverlight.com [mailto:ozsilverlight-boun...@ozsilverlight.com] On Behalf Of Miguel Madero Sent: Thursday, 28 January 2010 11:10 AM To: ozSilverlight Subject: Re: RIA Domain Services and required dependencies I've not experienced that issue. Try to explicitly validate the property to see if that's an issue with the DataForm or just with how you set up the validation. var ctx = new ValidationContext(this, null, null) { MemberName = NameOfYourPropertyGoesHere }; var validationResults = new CollectionValidationResult(); if (Validator.TryValidateProperty(yourNewValueGoesHere, ctx, validationResults)) // It was valid else // it wasn't valid, check the validationResults for details Could you also try it with the example on the link I sent? -- Miguel A. Madero Reyes www.miguelmadero.com (blog) m...@miguelmadero.com ___ ozsilverlight mailing list ozsilverlight@ozsilverlight.com http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight ___ ozsilverlight mailing list ozsilverlight@ozsilverlight.com http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight
Re: RIA Domain Services and required dependencies
It's ok, I think I figured it out. The attribute is not available on the client side. Within the generated code for the class, it was missing the TermCustomValidation class and it has the following message. So now I just have to figure out why the class isn't coming across to the client. T. // Unable to generate the following attribute due to the following error(s): // // - The attribute 'System.ComponentModel.DataAnnotations.CustomValidationAttribute' references type 'Brightstar.SSP.Web.Shared.TermCustomValidation' that is not accessible in the client project 'Brightstar.SSP.csproj'. Are you missing an assembly reference? // - The attribute 'System.ComponentModel.DataAnnotations.CustomValidationAttribute' references a method 'EnsureTermCategory' on type 'Brightstar.SSP.Web.Shared.TermCustomValidation' that is not accessible in the client project 'Brightstar.SSP.csproj'. // [CustomValidationAttribute(typeof (Brightstar.SSP.Web.Shared.TermCustomValidation), EnsureTermCategory, ErrorMessageResourceName = TTermCategoryRequiredError, ErrorMessageResourceType = typeof(Brightstar.SSP.Web.Resources.ValidationErrorResources))] // On Thu, Jan 28th, 2010 at 4:33 PM, ton...@tpg.com.au wrote: I just reflected over the code and found that it was using some reflection to retrieve the custom attributes. So I added in this code to see if the attributes were, in fact, visible. foreach (PropertyInfo info in typeof(Term).GetProperties()) { foreach (Attribute attribute in info.GetCustomAttributes(true).CastAttribute()) { Debug.WriteLine(attribute); } } And the answer is that it can see all the normal attributes, such as RequiredAttribute, DisplayAttribute, etc, but NOT the CustomValidationAttribute. Note that I have done a clean before building. I don't know why it's not recognising the CustomValidation attribute. Perhaps it is something to do with the meta data needing to map the particular attribute to the original class? T. On Thu, Jan 28th, 2010 at 3:32 PM, ton...@tpg.com.au wrote: Hi Miguel, I ran the code: var ctx = new ValidationContext(dfTermItem.CurrentItem, null, null) { MemberName = TermCategoryID }; var validationResults = new CollectionValidationResult(); //validate against a guid that should fail if (Validator.TryValidateProperty(new Guid(---0022-0002), ctx, validationResults)) { Debug.WriteLine(Success); } else { Debug.WriteLine(Fail); } It always returns Success and unfortunately, it didn't fire the Custom Validator at all. dfTermItem.CurrentItem is of type Term Term has a property TermCategoryID In the metadata.cs file, TermCategoryID is declared as follows: [CustomValidation(typeof (TermCustomValidation),EnsureTermCategory,ErrorMessageResourceName = TTermCategoryRequiredError, ErrorMessageResourceType = typeof (ValidationErrorResources))] [Bindable(true, BindingDirection.TwoWay)] public Guid TermCategoryID; TermCustomValidation is a static class: public static class TermCustomValidation { public static ValidationResult EnsureTermCategory(Guid TermCategoryID, ValidationContext validationContext) { Term currentTerm = validationContext.ObjectInstance as Term; if (currentTerm != null) { if (currentTerm.TermCategoryID == Guid.Empty) { return new ValidationResult(Term Type is a required field.); } //fyi, EnumHelper.GetID simply returns a guid from an attribute attached to an enum value if (currentTerm.TermCategoryID==EnumHelper.GetID(TermCategoryList.Vendor)) { if (currentTerm.VendorID == null || currentTerm.VendorID == Guid.Empty) { return new ValidationResult(Vendor is required when a Vendor Term Type is selected.); } } else if (currentTerm.TermCategoryID == EnumHelper.GetID(TermCategoryList.Model)) { if (currentTerm.ModelID == null || currentTerm.ModelID == Guid.Empty) { return new ValidationResult(Vendor, Brand and Model are required when a Model Term Type is selected.); } } } return ValidationResult.Success; } Note that it never actually debugs into the EnsureTermCategory method. I would have thought it would have returned Failed! Regards, Tony From: ozsilverlight-boun...@ozsilverlight.com
Re: RIA Domain Services and required dependencies
Try deleting the contents of the Generated_Code folder (it's hidden, use Show All Files to see it) - sometimes RIA Services stops updating the code files, but deleting them will get it generating them properly again. Also make sure that your custom validation code is in a .shared.cs file so it is being copied to the client. Chris Anderson 2010/1/28 ton...@tpg.com.au It's ok, I think I figured it out. The attribute is not available on the client side. Within the generated code for the class, it was missing the TermCustomValidation class and it has the following message. So now I just have to figure out why the class isn't coming across to the client. T. // Unable to generate the following attribute due to the following error(s): // // - The attribute 'System.ComponentModel.DataAnnotations.CustomValidationAttribute' references type 'Brightstar.SSP.Web.Shared.TermCustomValidation' that is not accessible in the client project 'Brightstar.SSP.csproj'. Are you missing an assembly reference? // - The attribute 'System.ComponentModel.DataAnnotations.CustomValidationAttribute' references a method 'EnsureTermCategory' on type 'Brightstar.SSP.Web.Shared.TermCustomValidation' that is not accessible in the client project 'Brightstar.SSP.csproj'. // [CustomValidationAttribute(typeof (Brightstar.SSP.Web.Shared.TermCustomValidation), EnsureTermCategory, ErrorMessageResourceName = TTermCategoryRequiredError, ErrorMessageResourceType = typeof(Brightstar.SSP.Web.Resources.ValidationErrorResources))] // On Thu, Jan 28th, 2010 at 4:33 PM, ton...@tpg.com.au wrote: I just reflected over the code and found that it was using some reflection to retrieve the custom attributes. So I added in this code to see if the attributes were, in fact, visible. foreach (PropertyInfo info in typeof(Term).GetProperties()) { foreach (Attribute attribute in info.GetCustomAttributes(true).CastAttribute()) { Debug.WriteLine(attribute); } } And the answer is that it can see all the normal attributes, such as RequiredAttribute, DisplayAttribute, etc, but NOT the CustomValidationAttribute. Note that I have done a clean before building. I don't know why it's not recognising the CustomValidation attribute. Perhaps it is something to do with the meta data needing to map the particular attribute to the original class? T. On Thu, Jan 28th, 2010 at 3:32 PM, ton...@tpg.com.au wrote: Hi Miguel, I ran the code: var ctx = new ValidationContext(dfTermItem.CurrentItem, null, null) { MemberName = TermCategoryID }; var validationResults = new CollectionValidationResult(); //validate against a guid that should fail if (Validator.TryValidateProperty(new Guid(---0022-0002), ctx, validationResults)) { Debug.WriteLine(Success); } else { Debug.WriteLine(Fail); } It always returns Success and unfortunately, it didn't fire the Custom Validator at all. dfTermItem.CurrentItem is of type Term Term has a property TermCategoryID In the metadata.cs file, TermCategoryID is declared as follows: [CustomValidation(typeof (TermCustomValidation),EnsureTermCategory,ErrorMessageResourceName = TTermCategoryRequiredError, ErrorMessageResourceType = typeof (ValidationErrorResources))] [Bindable(true, BindingDirection.TwoWay)] public Guid TermCategoryID; TermCustomValidation is a static class: public static class TermCustomValidation { public static ValidationResult EnsureTermCategory(Guid TermCategoryID, ValidationContext validationContext) { Term currentTerm = validationContext.ObjectInstance as Term; if (currentTerm != null) { if (currentTerm.TermCategoryID == Guid.Empty) { return new ValidationResult(Term Type is a required field.); } //fyi, EnumHelper.GetID simply returns a guid from an attribute attached to an enum value if (currentTerm.TermCategoryID==EnumHelper.GetID(TermCategoryList.Vendor)) { if (currentTerm.VendorID == null || currentTerm.VendorID == Guid.Empty) { return new ValidationResult(Vendor is required when a Vendor Term Type is selected.); } } else if (currentTerm.TermCategoryID == EnumHelper.GetID(TermCategoryList.Model)) { if (currentTerm.ModelID == null || currentTerm.ModelID == Guid.Empty) { return new
Re: RIA Domain Services and required dependencies
It was because I had forgotten to change the filename to have the .Shared.cs extension. Then I needed to do a clean and build again. Thanks all for the help. T. On Thu, Jan 28th, 2010 at 5:06 PM, Chris Anderson christheco...@gmail.com wrote: Try deleting the contents of the Generated_Code folder (it's hidden, use Show All Files to see it) - sometimes RIA Services stops updating the code files, but deleting them will get it generating them properly again. Also make sure that your custom validation code is in a .shared.cs file so it is being copied to the client. Chris Anderson 2010/1/28 ton...@tpg.com.au It's ok, I think I figured it out. The attribute is not available on the client side. Within the generated code for the class, it was missing the TermCustomValidation class and it has the following message. So now I just have to figure out why the class isn't coming across to the client. T. // Unable to generate the following attribute due to the following error(s): // // - The attribute 'System.ComponentModel.DataAnnotations.CustomValidationAttribute' references type 'Brightstar.SSP.Web.Shared.TermCustomValidation' that is not accessible in the client project 'Brightstar.SSP.csproj'. Are you missing an assembly reference? // - The attribute 'System.ComponentModel.DataAnnotations.CustomValidationAttribute' references a method 'EnsureTermCategory' on type 'Brightstar.SSP.Web.Shared.TermCustomValidation' that is not accessible in the client project 'Brightstar.SSP.csproj'. // [CustomValidationAttribute(typeof (Brightstar.SSP.Web.Shared.TermCustomValidation), EnsureTermCategory, ErrorMessageResourceName = TTermCategoryRequiredError, ErrorMessageResourceType = typeof(Brightstar.SSP.Web.Resources.ValidationErrorResources))] // On Thu, Jan 28th, 2010 at 4:33 PM, ton...@tpg.com.au wrote: I just reflected over the code and found that it was using some reflection to retrieve the custom attributes. So I added in this code to see if the attributes were, in fact, visible. foreach (PropertyInfo info in typeof(Term).GetProperties()) { foreach (Attribute attribute in info.GetCustomAttributes(true).CastAttribute()) { Debug.WriteLine(attribute); } } And the answer is that it can see all the normal attributes, such as RequiredAttribute, DisplayAttribute, etc, but NOT the CustomValidationAttribute. Note that I have done a clean before building. I don't know why it's not recognising the CustomValidation attribute. Perhaps it is something to do with the meta data needing to map the particular attribute to the original class? T. On Thu, Jan 28th, 2010 at 3:32 PM, ton...@tpg.com.au wrote: Hi Miguel, I ran the code: var ctx = new ValidationContext(dfTermItem.CurrentItem, null, null) { MemberName = TermCategoryID }; var validationResults = new CollectionValidationResult(); //validate against a guid that should fail if (Validator.TryValidateProperty(new Guid(---0022-0002), ctx, validationResults)) { Debug.WriteLine(Success); } else { Debug.WriteLine(Fail); } It always returns Success and unfortunately, it didn't fire the Custom Validator at all. dfTermItem.CurrentItem is of type Term Term has a property TermCategoryID In the metadata.cs file, TermCategoryID is declared as follows: [CustomValidation(typeof (TermCustomValidation),EnsureTermCategory,ErrorMessageResourceName = TTermCategoryRequiredError, ErrorMessageResourceType = typeof (ValidationErrorResources))] [Bindable(true, BindingDirection.TwoWay)] public Guid TermCategoryID; TermCustomValidation is a static class: public static class TermCustomValidation { public static ValidationResult EnsureTermCategory(Guid TermCategoryID, ValidationContext validationContext) { Term currentTerm = validationContext.ObjectInstance as Term; if (currentTerm != null) { if (currentTerm.TermCategoryID == Guid.Empty) { return new ValidationResult(Term Type is a required field.); } //fyi, EnumHelper.GetID simply returns a guid from an attribute attached to an enum value if (currentTerm.TermCategoryID==EnumHelper.GetID(TermCategoryList.Vendor)) { if (currentTerm.VendorID == null || currentTerm.VendorID == Guid.Empty) { return new