FormsModel-driven app

Field validation

How a form checks a value against the column's range, length, format and required settings before it saves.

Show me in the demoOpens the demo app with this component highlighted.

What it is

Validation shows a message next to a column when the value is not acceptable and stops the save until you fix it. Typical checks are a minimum and maximum on a number, a maximum length on text, a valid email address or URL, and a value in required columns. The message appears as soon as you leave the column.

When to use it

Define limits on the column itself whenever you can, so they hold on every form, view, import and flow. Use a business rule for conditions between columns, such as a negative price. Use a script with setNotification only for logic a rule cannot express.

Licensing and configuration

No extra licence. Set Minimum value, Maximum value, Maximum length, Format and Required on the column in the table designer. A business rule can also switch a column to Business Required on one form.

Pitfalls

  • Do not lower a maximum length on a column that already holds longer values.
  • A required column on a hidden tab or section does not block the save, unless the same column is also visible on the form.
  • Format settings such as Email and URL tell the form which control to use. Do not treat them as a complete data quality check.
  • A message set by a script stays until the script clears it, so clear it when the value is fixed.

Try it in the demo

  1. Find the Whole number, 0 to 5 field on the first accelerator.
  2. Type 7 and leave the field. Read the message about the allowed range.
  3. Replace it with 3 and watch the message disappear.
  4. Clear the Name field and try to save.