However, I want to add the validation to the communications options on the left side of the form. How do I bind the validation in the viewModelConfigDiff? Also, only communication options of type "phone number" should be validated.
Currently there is no way to add the validator using the regular approach with the validators property on the schema. However you can try adding it using the formControl for the ContactCommunicationOptionsItems (but note that this will be applied for phones, email, skype and web (in other words for all communication options)).
How to add the validator using formControl:
Implement the same validator on some separate field on the page
Find this validator in the context of the crt.HandleViewModelAttributeChangeRequest request execution (like request.$context._validators["AccountAccountCategory_List.value"][0]), but replace AccountAccountCategory_List.value with your attribute name on the page to which the validator is added. Also make sure array with only one element is returned (since you can have several validators for the same field and the array of validators can contain more than 1 element thus ...["AccountAccountCategory_List.value"][0] can return another validator.
In the context of the crt.HandleViewModelAttributeChangeRequest request (connected to the change of the ContactCommunicationOptionsItems attribute) add the following code:
But replace equest.$context._validators["AccountAccountCategory_List.value"][0] with the needed validator.
This is the only way to add the validator for this CommunicationOptions component (but once again note that this will be added to all the other communication options).
What's also strange is that when the handler is executed again (after I changed the field value), all properties of the formControl related to validation (asyncValidator, validator, _rawValidators, _rawAsyncValidators) are empty again!
Unfortunately no, this was the way I used locally and that worked and maybe the difference may arrise in the application version that was used for tests (8.2.2 in my case) or in other handlers maybe. This should be debugged only, there is no other way to identify what's wrong.