How is configuration data validated in ConfD? Is their a specific API for validation?

Validation of configuration in ConfD can be achieved in multiple ways.

The different ways of validation depend on what makes data valid (The constraint) from the systems perspective.

If the constraint for a configuration data is not dependent on other “variable data” in the system (example: a fixed max length of a string, a pattern, an interval of values for an integer), we can then express these constraints in a typedef element in YANG by using the different YANG statements for type restrictions.

If configuration data is purely dependent on other configuration data, then it is possible to express such constraints in the YANG model itself using must statements.

The above 2 methods are preferred, if the requirement allows for it. And the reason is because this type of validation is expressed directly in YANG and ConfD is able to process it without having to communicate with an external application (via sockets).

Now, If configuration data is dependent on data that is not store in CDB, there is a YANG extension (tail:validate) that allows YANG writers to instruct ConfD to validate data using a callback (An application has to register for this callback). This give applications more freedom in how to validate data (based on other constraints not available to ConfD).

The APIs to use to register validation callbacks in ConfD is:

confd_register_trans_validate_cb(): To register the init and stop callbacks for the validation transaction.

confd_register_valpoint_cb(): This one allows the registration of a validation callback for a given validation point (as specified in YANG using tailf:validate)

This API is accessible in the man page: man confd_lib_dp