Navigation :
test ../../../ test dev.html
Developer Guide
test ../../../ test dev/dev-release.html
-
Release and migration notes
test ../../../ test dev/getting-started.html
-
Getting started
test ../../../ test dev/dev-ui-config.html
-
Configuring the UI
test ../../../ test dev/dev-extensions.html
-
Extending the Module
test ../../../ test dev/dev-extensions/custom-cube-config.html
--
Adding Custom Cube Configuration
test ../../../ test dev/dev-extensions/custom-data-loading.html
--
Adding Custom Data Loading
test ../../../ test dev/dev-extensions/custom-evaluation.html
--
Adding Custom Evaluation Logic
test ../../../ test dev/dev-extensions/custom-limit-structure-templates.html
-- Adding Custom Limit Structure Templates
test ../../../ test dev/dev-extensions/custom-ui-exceptions.html
-- Adding Custom UI Exceptions
test ../../../ test dev/dev-extensions/custom-utilization.html
-- Adding Custom Utilization
test ../../../ test dev/dev-extensions/custom-validation.html
--
Adding Custom Validation
test ../../../ test dev/dev-extensions/custom-validation/custom-validators.html
--- Adding Custom Validators
test ../../../ test dev/dev-extensions/custom-validation/custom-validation-error-handling.html
--- Custom Validation Error Handling
test ../../../ test dev/dev-extensions/custom-workflow.html
--
Adding Custom Workflow Tasks
test ../../../ test dev/dev-extensions/custom-persistence.html
--
Adding Custom Persistence
test ../../../ test dev/dev-extensions/custom-limits-events.html
--
Sending Custom Events
test ../../../ test dev/integration.html
-
How to Connect Limits to an Atoti Server
test ../../../ test dev/persistence.html
-
Persistence
test ../../../ test dev/alert-tasks.html
-
Evaluating Limits
test ../../../ test dev/scopes.html
-
Limit scopes
test ../../../ test dev/limit-workflow.html
-
Limit Workflow
test ../../../ test dev/date-roll.html
- Date Roll
test ../../../ test dev/rest-services.html
- REST Services
test ../../../ test dev/roles.html
-
Roles and Permissions
test ../../../ test user-ref.html
User & Reference Guide
test ../../../ test user-ref/limits-overview.html
-
Atoti Limits Overview
test ../../../ test user-ref/whats-new.html
- What's New
test ../../../ test user-ref/videos.html
- Video walk-throughs
test ../../../ test user-ref/using-limits.html
-
Manage limits
test ../../../ test user-ref/manage-incidents.html
-
Manage incidents
test ../../../ test user-ref/input-files.html
-
Input file formats
test ../../../ test user-ref/cube.html
-
Cube reference
test ../../../ test user-ref/properties.html
-
Properties
test ../../../ test user-ref/datastore.html
-
Datastores
Adding Custom Validators
You can customize the validation performed when creating or updating limit structures, limits, and incidents by adding beans
that implement the ILimitStructureValidator
, ILimitValidator
, and IIncidentValidator
interfaces, respectively.
Here’s how to do this:
1. Create the Spring Bean(s)
These interfaces provide the explicit type parameter for the generically-typed IValidator
interface:
public interface ILimitStructureValidator extends IValidator< LimitStructure> {}
public interface ILimitValidator extends IValidator< Limit> {}
public interface IIncidentValidator extends IValidator< Incident> {}
To implement a custom validator, create a class that implements the appropriate interface and override its methods. A custom
implementation of ILimitValidator
could look like this:
@Component
public class MyLimitValidator implements ILimitValidator {
@Autowired
IValidationErrorHandler< Limit> validationErrorHandler;
@Getter private List< Limit> validObjects = new ArrayList<>();
@Getter private List< Limit> invalidObjects = new ArrayList<>();
@Override
public boolean validate ( Limit limit) {
// Custom validation logic
return true ;
}
@Override
public void preValidation ( Collection< Limit> limits) {
// Custom pre-validation logic
}
@Override
public void postValidation ( Collection< Limit> validatedLimits) {
// Custom post-validation logic
}
@Override
boolean validateTuple ( Object[] tuple, int lineNumber) {
// Custom tuple validation logic
return true ;
}
@Override
public IValidationErrorHandler< Limit> getValidationErrorHandler () {
return validationErrorHandler;
}
@Override
public void reset ( boolean throwException) {
validObjects. clear ();
invalidObjects. clear ();
validationErrorHandler. getValidationErrors (). clear ();
}
}
note
Note that the hasErrors
method is not overridden in the custom validator. The default implementation of this method in IValidator
is sufficient for most use cases.
2. Import the Spring Bean
Once the bean is created, import it into the project. See Importing Spring Beans into the Project on how to do this. Once done,
Spring will use the custom bean when validating the relevant object type.