Contentful logo

Contentful Community

Validation of unique item in an array

#1

We have content model which has one to many relation between product and countries in which it is available

Country is represented using separate content type having 2 unique fields - name and iso2

Product content type has field called availableCountries which is an array of items with allowed item type Country

Currently when editor is creating product he is able to select same country more than once, is there a way we can restrict editor to not select same country which is already selected and associated with current entry ?

Appreciate if someone can suggest any options or pointers?

Thanks,
Faizaan Shaikh

0 Likes

#2

Hi @faizaan.shaikh89,

It wouldn’t be possible to validate the individual items of an array directly through our Web Interface, but there would be two possibilities: 1) creating an UI extension to do this; 2) structure these items in a different way (e.g. using instead a referencing field)

0 Likes