Validate macro before inserting them


#1

Enonic version: 6.15.4
OS: Windows 10

I’ve needed to validate the data of macro before inserting them.
It’s possible in Enonic XP?


#2

Macro schema (the xml file you use to build a macro) is similar to content type schema, so you can use the same principles of validation there.

You can specify, for example, that a field is required

<input name="requiredField" type="TextLine">
  <label>Required field</label>
  <occurrences minimum="1" maximum="1"/>
</input>

or that a field should only allow some specific value pattern

<input name="ipAddress" type="TextLine">
  <label>Only numbers</label>
  <occurrences minimum="0" maximum="1"/>
  <config>
    <regexp>\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b</regexp>
  </config>
</input>

#3

This topic was automatically closed after 19 hours. New replies are no longer allowed.