How the check the validation status of a specific Property of a Business Object.

How the check the validation status of a specific Property of a Business Object.

Old forum URL: forums.lhotka.net/forums/t/11711.aspx


tarekahf posted on Monday, November 19, 2012

After executing :

PropertyHasChanged()

I need to check the result of the validation of that property, and I need to throw an error after running "PropertyHasChanged()". The error is same error generated by the Validation Routine of same property,

How I can check the validation status of a given property?

or

How I can execute the validation code and get the result of the validation (True/False)?

Tarek.

JonnyBee replied on Monday, November 19, 2012

Which version of CSLA do you use and for both sync/async rules?

Assuming CSLA 4.x you can check the validity of a field by either:

1. Use INotifyDataErrorInfo

((INotifyDataErrorInfo) <bo>)["<propertyName>"]

if this returns string.Empty or null there is no broken rules (with Severity=Error) else returns error message.
http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifydataerrorinfo%28v=vs.110%29.aspx

2. Use <bo>.BrokenRulesCollection and search for broken rules on a given property name (will give access to Error/Warning/Info).

 

 

tarekahf replied on Monday, November 19, 2012

Thanks JonnyBee,

I am using CSLA 2.0 (for .NET 2.0).

What is the method to check the validation status?

Tarek.

Copyright (c) Marimer LLC