Request Modeler supports custom validation for the fields in a request. The custom validation class must be created by implementing the ICanvasRuleEvaluator interface and overriding the following method:
Code Block | ||
---|---|---|
| ||
@Override |
...
public boolean evaluate(String fieldName, Object value, JSONObjectelemConfig, CanvasRuleEvaluationContext context) |
...
throws CanvasRuleException |
Custom validation JSON must be written in Validation rule (JSON) field while creating a request. JSON configuration must include the field IDs and values separated by commas along with the custom validation class.
Note |
---|
...
The custom validation class can have the validations in any format but the value it returns must be a Boolean. |
Example JSON:
Code Block | ||
---|---|---|
| ||
{ |
...
"initValidation": |
...
[{ |
...
"field":"EMP.EMP_NAME,EMP.EMP_AGE", |
...
"value":"John,35", |
...
"class":"com.intellectdesign.modelhouse.dataSupport.CustomEvaluatorValidation" |
...
}] |
...
} |
In the above example, the fields and its respective values that require validation are mentioned as different index in an array. The validations for these fields and values are available in com.intellectdesign.modelhouse.dataSupport.CustomEvaluatorValidation.