Reading annotations on validation rules in the document model

It’s possible to define annotations on the document model on validation rules. How can these rules be read from the front end code ? I haven’t seen them on the DocumentModel (kernel-md-facades)

For context, I’m trying to read annotations on validation rules when they are trigger in order to do ui changes based on the validation errors.

At the moment, there is no direct way to do it. This could be achieved as follows:

  1. get the IMetaModel-instance of the corrsponding DM, see IGeneratedCodeAccessor#getMetaModel()
  2. get the IMetaRule-instance of the rule, see IMetaModel.getValue(IMetaKeys.MODEL_META_RULE, $rule path$)
  3. get the annotation value of an specific annotation, see IMetaRule.getValue(IMetaKeys.RULE_ANNOTATION, $annotation key$)

Note: This way is about to be deprecated (especially IMetaModel and related), maybe in one of the ext-releases of 2023.06. You could create a requirement in order to have a solution for the situation.