ConfD User Community

Best practice for external validation points


#1

In my yang model, I have a few elements that need to be validated with external Python code.

Let’s say that in the same module I have leaves A and B that need to be validated, each of which with different Python code.

Using the “tailf:validate” extension, should I declare (and register in the Python code) a different validation call back for each leaf above or do I register one callback only, which will validate everything in sequence?

This:

leaf A {
    type string;
    tailf:validate vp {
        tailf:dependency ".";
    }
}
leaf B {
    type string;
    tailf:validate vp {
        tailf:dependency ".";
    }
}

or this:

leaf A {
    type string;
    tailf:validate vpA {
        tailf:dependency ".";
    }
}

leaf B {
    type string;
    tailf:validate vpB {
        tailf:dependency ".";
    }
}

#2

I would say it depends on your validation logic. If the validation shares same logic across several validation points, you can register same callback for each point. If the logic is different, it probably makes sense to register
separate callbacks.

Your validation callback will receive keypath, so you know which part of data model is validated. For Python see dp.register_valpoint_cb(...) in ConfD pyapi documentation.