CDB_SUB_PREPARE cannot be used for this. It is invoked in prepare phase against running database, which is after
commit operation. The difference between
CDB_SUB_COMMIT is, that when processing
CDB_SUB_PREPARE subscriptions, you can still abort
current transaction by calling
See ConfD UG - description of
cdb_subscribe2 function (in
confd_lib_cdb) and also ConfD transaction state diagram (e.g. in 7.5. User sessions and ConfD Transactions).
If you want to trigger error message immediately user enters command, you should also consider possible consequences in other northbound interfaces, which are different from CLI. This is the reason why validation is done in validate phase.
For CLI you may look at
clispec and override config commands with CLI custom commands (which fill appropriate configuration via
maapi) . This is possible if you have few commands that you need to check and display message.