Field type validator for links

Today I found a missing piece in the default item tree of a Sitecore instance. I did the finding on 9.3, so this may not apply to other Sitecore versions.

Background

There are basically a few different types of validators in Sitecore.

  • Field Rules (/sitecore/system/Settings/Validation Rules/Field Rules) are assignable to individual fields on a template and validates the content of a field.
  • Item Rules (/sitecore/system/Settings/Validation Rules/Item Rules) are assignable to items, typically to a template through __Standard values, and validates the content of an item as a whole. This could be item naming, structure, combination of field values etc.
  • Field Types (/sitecore/system/Settings/Validation Rules/Field Types) are Field Rules that apply to all instances of a field type. This could for example be validating URLs of all link fields in all items in the entire database.
  • Global Rules (/sitecore/system/Settings/Validation Rules/Global Rules) are Item Rules that apply to all items in the entire database.

The missing piece

There are two very similar field types in Sitecore: “General Link” and “General Link with search”. Internally they work exactly the same. It’s basically just the UI that’s slightly different. In most scenarios, I’d say the later one is preferred.

However, the Field Types validators only contains a “General Link” item. There is no “General Link with search” item, so no field type validators will be executed when you use this field type.

It’s a simple fix though. Just duplicate the “General Link” item and name it “General Link with search” and you’ll get validation rules on that field type as well. If you use both those field types in your solution, remember to keep those validator settings in sync.

Leave a Reply