Brightspot CMS Developer Guide

Providing error messages

Brightspot provides convenient APIs for displaying data validation and other error messages on the content edit form.

import com.psddev.cms.db.Content;
import com.psddev.cms.db.ToolUi;
import com.psddev.dari.db.State;

public class Galaxy extends Content {

    private String name;

    @ToolUi.Note("(light years)") 
    private String distanceFromEarth;

    protected void beforeSave() { 
        try {
        } catch (NumberFormatException e) { 
            State state = getState();
                 "Distance must be an integer (1234) or a floating-point number (1234.32)");
            throw new IllegalArgumentException("Resolve the errors listed below, then click Publish."); 

    public String getDistance() {
        return distanceFromEarth;

  • Declares a field for entering a distance.
  • Performs data validation prior to saving the object. Brightspot provides several callback methods with which you can perform validation.
  • Checks if the editor entered a number.
  • Displays a detailed error message above the field distanceFromEarth.
  • Displays a general error message at the top of the content edit form.

Providing error messages.svg Providing error messages.svg

Previous Topic
Content modeling annotations
Next Topic
Creating custom fields
Was this topic helpful?
Thanks for your feedback.
Our robust, flexible Design System provides hundreds of pre-built components you can use to build the presentation layer of your dreams.

Asset types
Module types
Page types
Brightspot is packaged with content types that get you up and running in a matter of days, including assets, modules and landing pages.

Content types
Landing pages
Everything you need to know when creating, managing, and administering content within Brightspot CMS.

Admin configurations
A guide for installing, supporting, extending, modifying and administering code on the Brightspot platform.

Field types
Content modeling
Rich-text elements
A guide to configuring Brightspot's library of integrations, including pre-built options and developer-configured extensions.

Google Analytics
Apple News