Validations

Expression Builder Validations Reference

Liferay 7.4 U67+/GA67+

You can create object field validations using Liferay’s Expression Builder. This tool provides an integrated editor for quickly defining complex validation rules using predefined fields, operators, and functions. You can browse available elements in the conditions side panel.

Important

Expression Builder validations can only be used with text, numeric, date, and Boolean field types.

Text Fields

Liferay provides the following operators and functions for Text and Long Text fields. You can use any of these fields as arguments. With some elements, you can also add string values to compare with the field’s value (e.g., "foo", "[A-Za-z]{1,50}").

Concat

Combines multiple strings or text fields and return a single string that can be used with other validation functions.

concat([textField], "[string]")

Condition (with Text)

Checks if user input meets one or more conditions and returns a Boolean value. This function works like if statements. Each expression includes at least one condition (e.g., textFieldName == "foo") and returns true or false. You can add multiple conditions to the same expression and determine a return value if none of the conditions are met (e.g., textFieldName == "foo", textFieldName == "bar", true, false).

condition([condition], [return-value])

Contains (with Text)

Checks if a text field contains a specific string value and returns a Boolean. If the field does not contain the value, it returns false.

contains([textField], "[string]")

Does Not Contain (with Text)

Checks if a text field does not contain a specific string value and returns a Boolean. If the field does contain the value, it returns false.

NOT(contains([textField], "[string]"))

Is a URL

Checks if a text field is a URL and returns a Boolean. If the field does not match a URL pattern, it returns false