Problem with validating CommunicationOptions items

Hi Creatio Community,

 

I'm trying to find a better solution for validating CommunicationOptions specifically for phonu numbers. With the code shown below, the validation works, but it's logic is applied for all type of items so email, phone number or Skype. Im trying to find something that could let me differentiate types and implement a logic only for that specific type (in my case phone numbers).

"ContactCommunicationOptionsDS_Number": {
                                    "modelConfig": {
                                        "path": "ContactCommunicationOptionsDS.Number"
                                    },
                                    "validators": {
                                        "validateOptions": {
                                            "type": "usr.Validator"
                                        }
                                    },
                                },
validators: /**SCHEMA_VALIDATORS*/{
			"usr.Validator": {
				"validator": function(config){
				return function(control){
					return null;
				};
			},
	        params: [],
			async: false
			}
		}/**SCHEMA_VALIDATORS*/

I know that there were some tickets already made in the past with almost no result, so if you need a validation logic and don't mind applying it on all types of communication, feel free to use it.

Best regards,

Tuan Dang.

Like 0

Like

2 comments

Hello,
For the more complex validation example, please take a look at this discussion:
https://community.creatio.com/questions/how-configure-field-validation-so-user-cannot-enter-number-smaller-value-another-field
The only way to achieve your goal is to use handlers and/or global variables

Hi. Thank you for your answer.

I don't really see how that ticket helps me. Here it's a different problem of not being able to differentiate CommunicationOptions from each other, because all I get is the string/input and not something like input and CommunicationOptionsType. 

With await request.$context you cannot even get the value. 

Show all comments