# defineValidation

> API reference for defineValidation: parameters, properties, and return types.

Defines a validation rule for a custom object.

```ts
import { defineValidation } from '@rippling/rippling-sdk';
```

## Properties

| Property | Required | Type | Description |
| --- | --- | --- | --- |
| `apiName` | Required | `` `${string}__c` `` | — |
| `displayName` | Required | `string` | Display name of this validation rule shown in the UI. |
| `errorMessage` | Required | `string` | User-facing error message shown when the validation fires.<br>Pass an empty string for no message. |
| `level` | Required | `[ValidationLevel](https://developer.rippling.com/documentation/js-sdk/metadata-sdk/reference/types/ValidationLevel-05692d02)` | Whether the error is shown at the record level or on a specific field.<br>One of `'RECORD'` \| `'FIELD'`. When `'FIELD'`, also set `fieldRef`. |
| `rqlFormula` | Required | `string` | RQL formula that returns `true` when the record is \*\*invalid\*\*.<br>Note the violation semantics: a truthy result triggers the error, not a passing check. Example: `'(end_time__c <= start_time__c)'` fires when end is not after start. |
| `ruleDescription` | Required | `string` | Internal description of this rule (for developer reference only).<br>Pass an empty string if unused. |
| `state` | Required | `[ValidationState](https://developer.rippling.com/documentation/js-sdk/metadata-sdk/reference/types/ValidationState-f9a3df92)` | Whether this rule is active or inactive.<br>One of `'ACTIVE'` \| `'INACTIVE'`. |
| `fieldRef` | Optional | `NoInfer<[DefinitionFieldReference](https://developer.rippling.com/documentation/js-sdk/metadata-sdk/reference/types/DefinitionFieldReference-fd4ee077)<TObject>>` | — |

[Complete options type](https://developer.rippling.com/documentation/js-sdk/metadata-sdk/reference/types/DefineValidationProps-4cc4b625)

## Parameters

| Parameter | Required | Type | Description |
| --- | --- | --- | --- |
| `object` | Required | `TObject` | — |

TypeScript signature

```ts
defineValidation<TObject extends ObjectReference>(object: TObject, props: DefineValidationProps<TObject>): Validation;
```

## Returns

```
Validation
```

## Availability

| Capability | Support |
| --- | --- |
| Pull into a project | Supported |
| Runtime operations | Not available for this helper |

Source: https://developer.rippling.com/documentation/js-sdk/metadata-sdk/reference/defineValidation

> For the complete documentation index, see [llms.txt](https://developer.rippling.com/llms.txt). Public pages have a Markdown version at the same URL with .md added.
