Data Validation in an Agent

In this Lesson

You will

  • Create a single-row agent for the PartyTheme table
  • Install a data validation in the agent

Concepts

Up to this point you have performed all data validations in the datasource’s validation pack. There are times when it is not appropriate to install validations in the datasource because the datasource does not have all the information needed to perform the validation.

Data validation can also be performed in an agent. This lesson will ask you to install a validation in an agent so that you can see how it is done.

Create a Single-row Agent

  1. Select the com.example.party.agent package and then open the Agent wizard



  2. Create an agent named PartyTheme as shown here



  3. Select all datasource values



  4. Provide a query name for view, change, and add modes.



  5. Build the agent
  6. Install a validation requiring the party theme to be provided
    1. Open the PartyTheme.java file



    2. Open the Override/Implement Methods dialog



    3. Select the validate_PartyTheme method



    4. Add the following syntax to the end of the validate_PartyTheme method.
      //a theme must be provided
      if (!hasContent(scheme.getPartyTheme())){
      	node.setMessage(error("A theme is required"));
      }
      
    5. The validate_PartyTheme method should now look like this



  7. Save the PartyTheme.java file.

End of lesson.