Jahia : maxlength constraint on a node property

174 views Asked by At

I've been looking for a few hours now for this simple question: how can I add a maxlength constraint on a jahia node text property?

What I've tried so far in the studio:

Jahia Studio example

I also tried seeting it directly in the definition.cnd, but cannot find any example or documentation about the max length of a text.

The property is a String TextArea, with no other specific property (but the maxlength I wanna add...)

Thanks in advance for any help!

1

There are 1 answers

0
Philippe Vollenweider On BEST ANSWER

You should use a regexp as a constraint. Typically your definition could be like this:

[jnt:test2] > jnt:content, jmix:basicContent
 - test2 (string, textarea) < '.{0,250}'

If you use the UI from the studio, you just need to add .{0,250} in the Value constraints input.

And you can also handle the error message in your resource bundle file by adding such key/value:

jnt_test2.test2.constraint.error.message=Please enter a valuer smaller than 250 chars