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

1 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.

Show all comments