Expand my Community achievements bar.

Custom validation to Asset Tag fields inside metadata editor in AEM as cloud

Avatar

Level 2

I am new to AEM DAM Assets . I am looking for i should apply custom validation to tag fields that i should allow only one tag in selection and show error in dialog. help me out how should i do custom validation.

Thanks in advance for your response.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

5 Replies

Avatar

Community Advisor

Hi @PrachiAt1 

You need to write either a clientlibs which will be act on either on tag field or on save to validate number of tag.

Or create a custom metadata schema to change tag selector field property multiple to false.

Arun Patidar

AEM LinksLinkedIn

Avatar

Community Advisor

Hi @PrachiAt1 ,

Option 1: Metadata Schema (No Code – Recommended)

If you're using metadata schema editor for asset properties:

Steps:

Go to Tools > Assets > Metadata Schemas.

Edit the schema that applies to your asset type (e.g., "default").

Find the Tag field (usually of type cq/gui/components/coral/common/form/tagfield).

Set the multiple property to false.

Result:

UI will only allow one tag selection.

No custom JS required.

No save-time validation needed—user can’t add more than one.


Option 2: Custom Validation with ClientLibs (For Dialogs)

If you're dealing with custom dialogs (not metadata schema), use client-side validation.

Add these to your component:

1. Dialog XML (cq:dialog):

<tags
    jcr:primaryType="nt:unstructured"
    sling:resourceType="cq/gui/components/coral/common/form/tagfield"
    name="./tags"
    fieldLabel="Tags"
    multiple="{Boolean}true"
    required="{Boolean}true"
    class="validate-single-tag"
/>


So,

Use Option 1 if you’re editing asset metadata via schema.

Use Option 2 if it’s a custom component dialog with tag fields.

Regards,
Amit

Avatar

Level 2

Hi @AmitVishwakarma Thanks for reply  i am looking for schema custom validation .

Thanks 

prachi.

Avatar

Community Advisor

Avatar

Level 4

Hi @PrachiAt1,

Did the shared solution help you out? Please let us know if you need more information. Otherwise kindly consider marking the most suitable answer as ‘correct’.

If you've discovered a solution yourself, we would appreciate it if you could share it with the community.