You should decorate the properties of the TheJuvenileClientContactItem type with the ObjectValidatorAttribute because Validation Application Block will not validate object graphs by default (to prevent performance problems and stack overflow exceptions).
Up vote 0 down vote favorite share g+ share fb share tw.
I am new to Enterprise Library. I am trying to validate a Business Object of type JuvenileClientContactItem. TheJuvenileClientContactItem objects itself has contained objects, in this case, two instances of objects of AddressType type.
When I perform the following call to validate the JuvenileClientContactItem, I expected that all contained objects would also be validated and any errors encountered in the PersonType object would be added to the ValidationResults collection, but only the validations on the JuvenileClientContactItem oject were performed. ValidationResults = validationService . Validate(Of JuvenileClientContactItem) _ (juvenileClientContactItem, _ "JuvenileClientContactItemRuleSet", "PersonTypeRuleSet") Here's the signature of the Enterprise Library Validate function: Public Shared Function Validate(Of T)(ByVal target As T, _ ByVal ParamArray rulesets() As String) _ As Microsoft.Practices.
EnterpriseLibrary.Validation. ValidationResults To validate the two Address sub objects within the JuvenileClientContactItem object, I need to perform separate calls to the Validate method, eg: residentaddressValidationResults = validationService . Validate(Of BusinessObjects.
AddressType) _ (juvenileClientContactItem. ResidenceAddress, _ Me. View, "AddressTypeRuleSet") I am tempted to write my own generic validation method that uses reflection to examine the object passed for validation looking for contained objects that are support self validation and perform calls and aggregate the results of all validations into a single returned collection.
Is there a better approach? Edit: Following the suggestion mentioned below, I added this code: _ _ _ _ Public Class AddressType ...And got the error that the ObjectValidatorAttribute can not ba applied because the attribute is not valid on this declaration type. Why?
How do I correct it? .net validation enterprise-library validation-application-bl link|improve this question edited Mar 23 '11 at 17:32 asked Mar 23 '11 at 16:53Chad2,20422162 85% accept rate.
You should decorate the properties of the TheJuvenileClientContactItem type with the ObjectValidatorAttribute, because Validation Application Block will not validate object graphs by default (to prevent performance problems and stack overflow exceptions).
Please see my edit regarding the error that I got when trying this: "ObjectValidatorAttribute can not ba applied because the attribute is not valid on this declaration type. " – Chad Mar 23 '11 at 17:33 @Velika: You should place the attribute on the property in the JuvenileClientContactItem type, not on the AddressType itself. – Steven Mar 23 '11 at 19:45 I tried.
Same error. – Chad Mar 23 '11 at 19:50 @Velika: Please post the code of the JuvenileClientContactItem class. – Steven Mar 23 '11 at 21:38 1 @Velika: You need to remove the ObjectValidator attribute from AddressType (and JuvenileClientContactItem class if you added on there) and place the ObjectValidator attribute on the property or field you wish to validate.
See msdn.microsoft.com/en-us/library/ff650581.aspx#Y1140 – Tuzo Mar 23 '11 at 22:49.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.