SuiteCRM Server Side Custom Validation

In certain cases, developers want to add custom validation on the server side. The reason for this might be for security. I know about using the ‘addToValidateCallback’ function to add custom client side validation.

Is there a way to add server side custom validation using logic hooks for example. The expected behaviour of the system would be to reload the form with the previous values for the fields populated if the request is invalid.

1 Like

I have the same question and one other:

Function addToValidate have “clean” message only text in from msg in call

function addToValidate(formname,name,type,required,msg)

but Function addToValidateCallback have addition text (for example Missing required field: msg from lable ERR_MISSING_REQUIRED_FIELDS)

function addToValidateCallback(formname,name,typ, required, msg, callback)

I want to change text from lable ERR_MISSING_REQUIRED_FIELDS to text from ERR_INVALID_VALUE, how can I do this?

Answer on my question is in the sugar_3.js

Message type of validation callback is HARDCODED as requiredTxt ( ERR_MISSING_REQUIRED_FIELDS) + Msg from addToValidateCallback, sometimes we need clean custom message, so in is only one way for me to change sugar_3.js?

{case'callback':if(typeof validate[formname][i][callbackIndex]=='function')
{var result=validate[formname][i][callbackIndex](formname,validate[formname][i][nameIndex]);if(result==false)
{isError=true;add_error_style(formname,validate[formname][i][nameIndex],requiredTxt+" "+validate[formname][i][msgIndex]);}}