Question

How to Apply Custom Validator to FreedomUI List?

You can register/apply validators to fields on the page using these instructions: https://academy.creatio.com/docs/developer/front_end_development_freedo…



But how can you apply a validator to an editable field within a list or a "collection" data source?



If you try to add a validator to the field as normal e.g.

 

viewModelConfigDiff: /**SCHEMA_VIEW_MODEL_CONFIG_DIFF*/[
{
	"operation": "merge",
	"path": [
		"attributes"
	],
	"values": {
		"ContactCommunicationOptionsItems": {
		"isCollection": true,
		"modelConfig": {
			"path": "ContactCommunicationOptionsDS",
			"sortingConfig": {
				"default": [
					{
						"columnName": "CreatedOn",
						"direction": "asc"
					}
				]
			}
		},
		"viewModelConfig": {
			"attributes": {
				"ContactCommunicationOptionsDS_CreatedOn": {
					"modelConfig": {
						"path": "ContactCommunicationOptionsDS.CreatedOn"
					}
				},
				"ContactCommunicationOptionsDS_Number": {
					"modelConfig": {
						"path": "ContactCommunicationOptionsDS.Number"
					},
					"validators": {
						"TESTValidator": {
							"type": "q.TestValidator",
							"params": {}
						}
					}
				},
				.....



An error in the console is displayed: Error: Validator 'q.TestValidator' was not registered. 



How do I "register" a validator to work within a list?

Like 0

Like

2 comments
Best reply

Hi,

Currently, you cannot add the validator to an editable list.

Contacted the developers about the possibility of adding such an option and they confirmed that they are working on this logic, however, it will only be available in the future version. We will increase the priority of this task so it will be done quicker.

Hi,

Currently, you cannot add the validator to an editable list.

Contacted the developers about the possibility of adding such an option and they confirmed that they are working on this logic, however, it will only be available in the future version. We will increase the priority of this task so it will be done quicker.

Dmytro Vovchenko,
 

Any update on this, a client is requesting something similar to what was asked in this post. We want to have a validator which will check if any duplicate emails exist when the email is updated on the ContactCommunication panel. We already have indexing set-up to prevent the duplication on a database level, but we want a validator as well so it is clear to user's when an email is a duplicate.

Show all comments