Field-Level Validation Code Examples
The following sample class implements custom validation logic on an Integer field, and extends the OperationValidator class.
package com.servicemax.example;

import com.servicemax.core.validator.OperationValidator;

class MyIntegerFieldValidator extends OperationValidator {

public Object realValidator(Map<String, Object> params) {
//verify whether the field under validation for the current record is not zero (integer field)
if(recordUnderValidation.getFieldValue(fieldUnderValidation) == 0) {
//if the value is zero, log the error
logger.error("The {} is zero for record {}", fieldUnderValidation, recordUnderValidation.svmx_name)
//and generate a field validation error
addFieldValidationError(fieldUnderValidation, "The \"$fieldUnderValidation\" Field can not be zero.") // This adds an error to the validation, then record will not be saved
}
}
}
* 
For details on how to configure field-level custom validation, see Configuring Field-Level Custom Validation in Service Board for Implementers.
For more information:
Was this helpful?