[SalesForce] REST API & Validation Rules error

Question

Is there any way to determine which validation-rule caused an error on a POST to REST API?

Background

I have a customObject A__c which has many Validation Rules. Also, I'm trying to insert/update values by REST API.

As expected, validation rules work fine after posting invalid data, returning a json object like this:

[
{
"fields":[
],
"message":"Name should start with XXXX",
"errorCode":"FIELD_CUSTOM_VALIDATION_EXCEPTION"
}
] 

I need to know which validation rule exception was thrown. In addition, I can't use the message attribute for this because the app is translated into many languages.

I looked at the official errors doc, but there was nothing there.

Any idea?

Update:

I'm developing a mobile app, this app has a form to complete and post the object A__c. I need to know which fields have error when I post in order to highlight them and show the error message on each invalid field.
The object validation rules are created and updated in salesforce,so I'm not able to validate in client-side.

Best Answer

The response will return the API Name of the field in the "fields" array of the response. But only if the Error Location of the Validation Rule is configured correctly.

The Field needs to be selected from the picklist when creating (or modifying) the validation rule. This is shown in the screenshot below

Validation rule on a Field

When I violate the example validation rule above, my json response is:

[ {
    "fields" : [ "BillingCity" ],
    "message" : "This Billing City is a bad choice, please select another.",
    "errorCode" : "FIELD_CUSTOM_VALIDATION_EXCEPTION"
} ]

So as long as the Error Location on each Validation Rule is specified as 'Field', you will be able to place the error message next the right field in your mobile app.