Validation in content types

I know this is probably difficult to create, and therefore wishful thinking, but it would be awesome if it was possible to add validation or conditions in the content type configuration (XP), beyond min and max occurences.

What I am thinking about, is to add something like

if <input x> has value <A>
  display <input y>
else
  display <input z>

Or

require <input x> OR <input y>

Basically a more advanced form builder…

Custom validation error messages would also be nice to have.

A possible solution could allowing developers to add JavaScript code to be used in the content creation form. (This would probably be easier than creating logic like this to be used universally, though I suppose there are multiple implications I am not aware of)

I haven’t looked enough on XP yet, so I suppose it is possible I could find other ways of doing this, but it is something which I have faced the need for in 4.7 many times.

1 Like

Not just wishful thinking - this is a design idea, actually there is already some JavaScript support in The content type, as you can define “display-name-scripts”

Check out this https://github.com/enonic/xp-sample-modules/blob/master/modules/features/src/main/resources/cms/content-types/display-name-script/content-type.xml

Plan is to enable more advanced features like you talk about later…

1 Like

Nice! I’ll have to check that out later.

Looking forward to more features like that later. :smile:

1 Like