Validating Field Values

After a user has configured a component using your custom source configuration type and saved it, you can perform validation of the provided field values.

You can use the CommonIntegrator method getAlerts()to validate the provided values. If the values are invalid, you can return a collection of alert messages to the UI. The default implementation of this method returns nothing. This method can be treated as a way to prevent integration failures by pre-checking all the required values.

An example implementation is as follows:

Private File location = null;

public Collection<String> getAlerts(Locale locale) throws Exception {
    if(location == null)
        return Arrays.asList("The Base Directory cannot be empty");

    File toCheck = new File(location);
    if(toCheck.exists())
        return null;

    return Arrays.asList("The Base Directory does not exists");
}