xal replied on Monday, September 04, 2006
Jason,
Instance Validation / Authorization rules is what we've had all along. That means:
An object is instanced, a method is called so that you can load the rules, you create instances of validation rules that will be specific to that object.
When you make another instance of the same type, the process is repeated exactly like that.
With the new shared V / A rules this is what happens:
An object of type XYZ is instanced for the first time. The AddBusinessRules method is called so that you can load the rules and, in there, you create instances of validation rules that will apply to ALL objects of the same type.
When you make another instance of the same type, the AddBusinessRules method never gets called, because the rules are already loaded for that type.
When using Shared rules, make sure you define your rule methods as static/shared. You must use the target parameter of the rule method to run the validation. Here's a sample of how you can use all the latest to validate something:
Shared Validation Rule SampleAndrés