> This page is for Docs.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://zuora.ferndocs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://zuora.ferndocs.com/_mcp/server.

# Format of validation functions

> Describes the format of validation functions, such as function syntax, parameters, and return values.

Describes the format of validation functions, such as function syntax, parameters, and return values.

You can use validation functions to define validation rules on object fields to ensure data accuracy and consistency.

Zuora calls validation functions on the creation or update of a specific object record and uses the record as the only parameter.

The fields that can be used in validation functions vary depending on the object type. For more information, see [Objects and fields supported by Custom Logic](/docs/platform/extensibility/custom-logic/objects-and-fields-supported-by-custom-logic).

## Syntax

```
((object_record) => {
    //JavaScript code(validation rules)
})(object_record)
```

## Parameters

The function takes one parameter `object_record`. This parameter is required and the parameter name is not editable. The parameter name varies depending on the related object type.

The following table lists the parameter names for some common standard and custom objects:

| Object name             | Parameter name     |
| ----------------------- | ------------------ |
| Account                 | account            |
| Product                 | product            |
| Vehicle (custom object) | default\_\_vehicle |

When a function is called, Zuora provides the context object record as the input value. For example, if the function is called during the creation of an account object record, the parameter name is `account`, which refers to this specific account object record.

## Return value

The return value is an object of the following format:

```json
{
    success: boolean,
    message?: string
}
```

<table>
  <tr>
    <th>
      Key
    </th>

    <th>
      Required
    </th>

    <th>
      Value format
    </th>

    <th>
      Description
    </th>
  </tr>

  <tr>
    <td>
      success
    </td>

    <td>
      Yes
    </td>

    <td>
      Boolean
    </td>

    <td>
      Indicating the running result of the function:

      * `true`: The data evaluation succeeded. Zuora will create or update the object record.
      * `false`: The data evaluation failed. Zuora will not create or update the object record.
    </td>
  </tr>

  <tr>
    <td>
      message
    </td>

    <td>
      No
    </td>

    <td>
      String
    </td>

    <td>
      The message displayed when the data evaluation fails.
    </td>
  </tr>
</table>

## Example

```
((account) => {
    if (account.Country__c === 'United States' && !account.BillingState__c) {
        return {
            success: false,
            message: "Billing State is required for accounts in the United States."
        };
    }
    return { success: true };
})(account);
```

In this example, the function checks whether the `BillingState__c` custom field is specified when the value in the `Country__c` custom field is `United States`.

If `success` is `true` in the returned object, Zuora will create or update the account object record by using the data from `account`. If `success` is `false`, Zuora will display the following error message and not create or update the account object record.

`Billing State is required for accounts in the United States.`

With the help of this validation function, you can ensure the `BillingState__c` custom field is conditionally required every time an account object record is created or updated.