Strict SET_ type enforcement?

I have a leaf that is defined as a string of length 5. I accidentally used SET to return a length 10 string, which was accepted (but failed validation on the other device because they checked the length).

Is there a way to get feedback internally that I’m violating a type restriction in the yang when I’m writing the data within the callback?

leaf id { type string { length 5; } }

char id[BUFSIZE] = {0};
snprintf(id, sizeof(id) - 1, "0000000000");

id fails type checks at other end due to invalid length

CONFD_SET_STR() is a convenience macro, not an API. You have the source of those macros in $CONFD_DIR/include/confd_lib.h.

If you want to check against the schema (YANG model) for such a restriction, you can start a MAAPI transaction and try to set the data using maapi_set_elem()/elem2(). When done, close the transaction without applying/committing it.