Validation callbacks

Hi,

I have implemented the validation callbacks for the validation points.
I understand that if the validation failed, the call back of the data validation should fail.
Since we work with external DB, we can have few validation point which one depends on the other and one depends on other configuration in the DB. For example, only when the data of validation point 1 and validation point 2 is given, we can check the validation together with the other external configuration.
we think that the best proceedure for us is to set the changed data in the data validation callback (we do it using the maapi iter utility). only when all is set we should check the dependent validation. When I tried to check the validity in validation stop callback I could not fail the valdiation if needed.
Do we have a knowledge how many data validation call backs should be called for the commit check? If so, it might be helpfull.
Do you have other suggestion of how to implement that - what we are trying to get is set the data for validity check and after all the data is set for all the validation points, only then to actually check the validation itself in the DB.

thanks
Inbal

If I understand your problem correctly, I think the best/cleanest solution would be to use the tailf:priority substatement to tailf:validate:

   tailf:priority This extension takes an integer parameter specifying the
   order validation code will be evaluated, in order of increasing
   priority.

   The default priority is 0.

I believe you should then be able to assign priorities such that if the callback for validation point A depends on the callback for validation point B having been run successfully, the callback for A is always invoked after the callback for B (assuming both are called).

Of course all validation callbacks have access to all the data in the transaction, and can use MAAPI to read whatever they want - they’re not restricted to the leaf value passed to the callback and maapi_diff_iterate(). In fact using maapi_diff_iterate() in validation callbacks is typically not a good idea - it suggests that you are trying to validate the changes, and not the resulting configuration, which is always a bad idea. See the “Semantic Validation” chapter in the User Guide.

Hi,

Thank you for the recommandation for the tailf:priority. It will give me the solution for the order issue.
However, I would like to perform the commit check in the external DB only once, after all the data for validation was recevied.

I looked at the transaction data and could not find a hint of how to do it - is there a way to know that there is no more valdiation data to receive?

thanks
Inbal

In that case it seems to me that you should have a single validation point, with all the dependencies specified.[quote=“InbalAmram, post:3, topic:1448”]
is there a way to know that there is no more valdiation data to receive?
[/quote]
Not as such. I guess you could have a validation point as above in addition to the others, and give it a higher priority than all the others. Then you know that no other callbacks will be invoked after it.

But I definitely think that you should let each callback do “its own” validation instead.

By the way, whether your data is stored in an external DB or in CDB is irrelevant with respect to validation callbacks - they should always read the data they need from the transaction via MAAPI.