Validation
Introduction
Validators help protect data integrity by ensuring that only data meeting specific conditions is accepted into the system. For example, when dealing with text type attributes, you can use regular expressions (regex). Imagine regex as a pattern that checks whether the attribute value is correct; for example, it checks if an email address contains an "@" symbol. This helps maintain accuracy and prevents errors.
Different attribute types require different validation rules. A number might need to be within a certain range, whereas an image might need to fall within specific boundaries. Validators thus help maintain consistency across your data fields.
In Ergonode you can set validation to the following attribute types:
File
Min. number of files
Max. number of files
Max. file size
Allowed extensions
Gallery
Min. number of images
Max. number of images
Max. file size
Allowed extensions
Image
Max. file size
Allowed extensions
Numeric
Min. value
Max. value
Price
Min. value
Max. value
Text
Regular expression (regex) with examples
Textarea
Banned words (1000 characters limit)
Unit
Min. value
Max. value
Max. file size is set in KB. Allowed extensions opens a list of file extensions: tick the ones you allow and click on Ok, or click on Clear to empty the field. In Banned words, press ENTER after each word or paste the words from a spreadsheet.
About regex (available in text attribute only)
Regular expressions, or regex, are like super-powered validation tools for text. They use a specific sequence of characters to form a specific pattern. You can think of it as a sophisticated “find,” but with more precision and flexibility. Here's how to use regex for validating:
Basic Validation:
Suppose you want to validate any three-letter words. You'd use the pattern
\b\w{3}\b. In this pattern,\bindicates word boundaries, and\w{3}specifies exactly three word characters.
Digits Validation:
To validate any sequence of digits in text, use the pattern
\d. Here,\dstands for any digit, so this will match any sequence of strings with a single digit in it, like 123, 4aa, or 678aaa9. If you wish to validate a string that ends with a digit use\d$, ex: something1.
Email Addresses Validation:
To validate email addresses, you might use something like
\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b. This looks for common email structures, checking for alphanumeric characters before and after the "@" symbol.
Dates validation:
To validate the dates in the format DD/MM/YYYY, you could use
\b\d{2}\/\d{2}\/\d{4}\b. Here,\d{2}finds exactly two digits,/is a literal slash, and\d{4}looks for four digits.
Flexible Validation:
Sometimes, you might want to validate words that start with a certain letter. For example, to find words starting with “a” use
\ba\w*\b. This looks for word boundaries (\b), the letter "a," and any number of word characters (\w*).
Regex provides a way to quickly find patterns and extract relevant information from text without manual searching. They might seem complex at first, but with practice, they become incredibly useful for tasks like data validation and text processing. Dive in and explore the endless possibilities they offer!
Available regex templates
In Ergonode you will find some common regex patterns already included for your convenience.
Here is the list:
Barcode EAN-13
Barcode EAN-8
URL Address
File Path
Alphanumeric (without space)
Alphanumeric (with space)
Numeric (whole numbers)
Numeric (dot separated)
Numeric (comma separated)
To use them click on Copy from regex templates.

In the Regex templates window, click Apply next to the template you need to copy its pattern to the Regular expression (regex) field.

Custom regex validation error message
You can set a custom error message for your user in the Validation error message field.

You can test the validation before saving it. Enter a value in the Attribute value field of the Try out validation panel to check if it will be allowed to be saved. Don't forget to click on Save changes.
The message will be displayed in the Try out validation panel

in the tooltip on the Product catalog (Product grid)

in the Category attribute (if the attribute is set to be one)

in the Batch action

and on the product card.

Last updated
Was this helpful?

