# Data Validation

> Language fallback: requested `zh-CN`; content is `en-US`.

- Human documentation: [https://docs.univer.ai/zh-CN/reference/facade/data-validation](https://docs.univer.ai/zh-CN/reference/facade/data-validation)

- Agent Markdown: [https://docs.univer.ai/zh-CN/reference/facade/data-validation.md](https://docs.univer.ai/zh-CN/reference/facade/data-validation.md)

- Requested language: `zh-CN`

- Content language: `en-US`

- Documentation version: `1.0.0-rc.0`

- Source: [facade/data-validation.mdx](https://github.com/dream-num/documentation/blob/dev/content/reference/facade/data-validation.mdx)

---

| Packages | `@univerjs/sheets-data-validation` |
| -------- | ---------------------------------- |

> This class should not be instantiated directly. Use factory methods on `univerAPI` instead.

## Overview

### @univerjs/sheets-data-validation

| Method                                                                    | Description                                                                                                            |
| ------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| [`build`](#build)                                                         | Builds an FDataValidation instance based on the \_rule property of the current class                                   |
| [`copy`](#copy)                                                           | Creates a new instance of FDataValidationBuilder using the current rule object                                         |
| [`delete`](#delete)                                                       | Delete the data validation rule from the worksheet                                                                     |
| [`getAllowInvalid`](#getallowinvalid)                                     | Gets whether invalid data is allowed based on the error style value                                                    |
| [`getApplied`](#getapplied)                                               | Gets whether the data validation rule is applied to the worksheet                                                      |
| [`getCriteriaType`](#getcriteriatype)                                     | Gets the data validation type of the rule                                                                              |
| [`getCriteriaValues`](#getcriteriavalues)                                 | Gets the values used for criteria evaluation                                                                           |
| [`getHelpText`](#gethelptext)                                             | Gets the help text information, which is used to provide users with guidance and support                               |
| [`getRanges`](#getranges)                                                 | Gets the ranges to which the data validation rule is applied                                                           |
| [`getSheetId`](#getsheetid)                                               | Gets the sheet ID of the worksheet                                                                                     |
| [`getUnitId`](#getunitid)                                                 | Gets the unit ID of the worksheet                                                                                      |
| [`requireCheckbox`](#requirecheckbox)                                     | Sets the data validation rule to require that the input is a boolean value; this value is rendered as a checkbox       |
| [`requireDateAfter`](#requiredateafter)                                   | Set the data validation type to DATE and configure the validation rules to be after a specific date                    |
| [`requireDateBefore`](#requiredatebefore)                                 | Set the data validation type to DATE and configure the validation rules to be before a specific date                   |
| [`requireDateBetween`](#requiredatebetween)                               | Set the data validation type to DATE and configure the validation rules to be within a specific date range             |
| [`requireDateEqualTo`](#requiredateequalto)                               | Set the data validation type to DATE and configure the validation rules to be equal to a specific date                 |
| [`requireDateNotBetween`](#requiredatenotbetween)                         | Set the data validation type to DATE and configure the validation rules to be not within a specific date range         |
| [`requireDateOnOrAfter`](#requiredateonorafter)                           | Set the data validation type to DATE and configure the validation rules to be on or after a specific date              |
| [`requireDateOnOrBefore`](#requiredateonorbefore)                         | Set the data validation type to DATE and configure the validation rules to be on or before a specific date             |
| [`requireFormulaSatisfied`](#requireformulasatisfied)                     | Sets the data validation rule to require that the given formula evaluates to `true`                                    |
| [`requireNumberBetween`](#requirenumberbetween)                           | Sets the data validation rule to require a number that falls between, or is either of, two specified numbers           |
| [`requireNumberEqualTo`](#requirenumberequalto)                           | Sets the data validation rule to require a number equal to the given value                                             |
| [`requireNumberGreaterThan`](#requirenumbergreaterthan)                   | Sets the data validation rule to require a number greater than the given value                                         |
| [`requireNumberGreaterThanOrEqualTo`](#requirenumbergreaterthanorequalto) | Sets the data validation rule to require a number greater than or equal to the given value                             |
| [`requireNumberLessThan`](#requirenumberlessthan)                         | Sets the data validation rule to require a number less than the given value                                            |
| [`requireNumberLessThanOrEqualTo`](#requirenumberlessthanorequalto)       | Sets the data validation rule to require a number less than or equal to the given value                                |
| [`requireNumberNotBetween`](#requirenumbernotbetween)                     | Sets the data validation rule to require a number that does not fall between, and is neither of, two specified numbers |
| [`requireNumberNotEqualTo`](#requirenumbernotequalto)                     | Sets the data validation rule to require a number not equal to the given value                                         |
| [`requireValueInList`](#requirevalueinlist)                               | Sets a data validation rule that requires the user to enter a value from a list of specific values                     |
| [`requireValueInRange`](#requirevalueinrange)                             | Sets a data validation rule that requires the user to enter a value within a specific range                            |
| [`rule`](#rule)                                                           | -                                                                                                                      |
| [`setAllowBlank`](#setallowblank)                                         | Sets whether to allow blank values                                                                                     |
| [`setAllowInvalid`](#setallowinvalid)                                     | Sets whether to allow invalid data and configures the error style                                                      |
| [`setCriteria`](#setcriteria)                                             | Set Criteria for the data validation rule                                                                              |
| [`setOptions`](#setoptions)                                               | Sets the options for the data validation rule                                                                          |
| [`setRanges`](#setranges)                                                 | Set the ranges to the data validation rule                                                                             |

## APIs

### Lifecycle & Creation

### `build`

Builds an FDataValidation instance based on the \_rule property of the current class

**Signature**

```typescript
build(): FDataValidation
```

**Returns**

* `FDataValidation` — A new instance of the FDataValidation class

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Create a new data validation rule that requires a number between 1 and 10 for the range A1:B10
const fRange = fWorksheet.getRange('A1:B10');
const rule = univerAPI.newDataValidation()
  .requireNumberBetween(1, 10)
  .setOptions({
    allowBlank: true,
    showErrorMessage: true,
    error: 'Please enter a number between 1 and 10'
  })
  .build();
fRange.setDataValidation(rule);
```

Source: 

`@univerjs/sheets-data-validation`

### Getters & Queries

### `getAllowInvalid`

Gets whether invalid data is allowed based on the error style value

**Signature**

```typescript
getAllowInvalid(): boolean
```

**Returns**

* `boolean` — true if invalid data is allowed, false otherwise

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
const rules = fWorksheet.getDataValidations();
rules.forEach((rule) => {
  console.log(rule, rule.getAllowInvalid());
});
```

Source: 

`@univerjs/sheets-data-validation`

### `getApplied`

Gets whether the data validation rule is applied to the worksheet

**Signature**

```typescript
getApplied(): boolean
```

**Returns**

* `boolean` — true if the rule is applied, false otherwise

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
const rules = fWorksheet.getDataValidations();
rules.forEach((rule) => {
  console.log(rule, rule.getApplied());
});

const fRange = fWorksheet.getRange('A1:B10');
console.log(fRange.getDataValidation()?.getApplied());
```

Source: 

`@univerjs/sheets-data-validation`

### `getCriteriaType`

Gets the data validation type of the rule

**Signature**

```typescript
getCriteriaType(): DataValidationType | string
```

**Returns**

* `string` — The data validation type

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
const rules = fWorksheet.getDataValidations();
rules.forEach((rule) => {
  console.log(rule, rule.getCriteriaType());
});
```

Source: 

`@univerjs/sheets-data-validation`

### `getCriteriaValues`

Gets the values used for criteria evaluation

**Signature**

```typescript
getCriteriaValues(): [string, string, string]
```

**Returns**

* `[string, string, string]` — An array containing the operator, formula1, and formula2 values

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
const rules = fWorksheet.getDataValidations();
rules.forEach((rule) => {
  console.log(rule);
  const criteriaValues = rule.getCriteriaValues();
  const [operator, formula1, formula2] = criteriaValues;
  console.log(operator, formula1, formula2);
});
```

Source: 

`@univerjs/sheets-data-validation`

### `getHelpText`

Gets the help text information, which is used to provide users with guidance and support

**Signature**

```typescript
getHelpText(): string | undefined
```

**Returns**

* `string` — Returns the help text information. If there is no error message, it returns an undefined value

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
const fRange = fWorksheet.getRange('A1:B10');
const rule = univerAPI.newDataValidation()
  .requireNumberBetween(1, 10)
  .setOptions({
    allowBlank: true,
    showErrorMessage: true,
    error: 'Please enter a number between 1 and 10'
  })
  .build();
fRange.setDataValidation(rule);
console.log(fRange.getDataValidation().getHelpText()); // 'Please enter a number between 1 and 10'
```

Source: 

`@univerjs/sheets-data-validation`

### `getRanges`

Gets the ranges to which the data validation rule is applied

**Signature**

```typescript
getRanges(): FRange[]
```

**Returns**

* `FRange[]` — An array of FRange objects representing the ranges to which the data validation rule is applied

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
const rules = fWorksheet.getDataValidations();
rules.forEach((rule) => {
  console.log(rule);
  const ranges = rule.getRanges();
  ranges.forEach((range) => {
    console.log(range.getA1Notation());
  });
});
```

Source: 

`@univerjs/sheets-data-validation`

### `getSheetId`

Gets the sheet ID of the worksheet

**Signature**

```typescript
getSheetId(): string | undefined
```

**Returns**

* `string` — The sheet ID of the worksheet

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
const fRange = fWorksheet.getRange('A1:B10');
console.log(fRange.getDataValidation().getSheetId());
```

Source: 

`@univerjs/sheets-data-validation`

### `getUnitId`

Gets the unit ID of the worksheet

**Signature**

```typescript
getUnitId(): string | undefined
```

**Returns**

* `string` — The unit ID of the worksheet

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
const fRange = fWorksheet.getRange('A1:B10');
console.log(fRange.getDataValidation().getUnitId());
```

Source: 

`@univerjs/sheets-data-validation`

### Setters & Modifiers

### `setAllowBlank`

Sets whether to allow blank values.

**Signature**

```typescript
setAllowBlank(allowBlank: boolean): FDataValidationBuilder
```

**Parameters**

* `allowBlank` `boolean` — *No description*

**Returns**

* `FDataValidationBuilder` — The current instance for method chaining.

**Examples**

```ts
// Assume current sheet is empty data
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Set the data validation for cell A1:B2 to allow blank values
const fRange = fWorksheet.getRange('A1:B2');
const rule = univerAPI.newDataValidation()
  .requireValueInList(['Yes', 'No'])
  .setAllowBlank(true)
  .build();
fRange.setDataValidation(rule);

// Set the data validation for cell C1:D2 to not allow blank values
const fRange2 = fWorksheet.getRange('C1:D2');
const rule2 = univerAPI.newDataValidation()
  .requireValueInList(['Yes', 'No'])
  .setAllowBlank(false)
  .build();
fRange2.setDataValidation(rule2);
```

Source: 

`@univerjs/sheets-data-validation`

### `setAllowInvalid`

Sets whether to allow invalid data and configures the error style.
If invalid data is not allowed, the error style will be set to STOP, indicating that data entry must stop upon encountering an error.
If invalid data is allowed, the error style will be set to WARNING, indicating that a warning will be displayed when invalid data is entered, but data entry can continue.

**Signature**

```typescript
setAllowInvalid(allowInvalidData: boolean): FDataValidationBuilder
```

**Parameters**

* `allowInvalidData` `boolean` — *No description*

**Returns**

* `FDataValidationBuilder` — The current instance for method chaining.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Set the data validation for cell A1:B2 to allow invalid data, so A1:B2 will display a warning when invalid data is entered
const fRange = fWorksheet.getRange('A1:B2');
const rule = univerAPI.newDataValidation()
  .requireValueInList(['Yes', 'No'])
  .setAllowInvalid(true)
  .build();
fRange.setDataValidation(rule);

// Set the data validation for cell C1:D2 to not allow invalid data, so C1:D2 will stop data entry when invalid data is entered
const fRange2 = fWorksheet.getRange('C1:D2');
const rule2 = univerAPI.newDataValidation()
  .requireValueInList(['Yes', 'No'])
  .setAllowInvalid(false)
  .build();
fRange2.setDataValidation(rule2);
```

Source: 

`@univerjs/sheets-data-validation`

### `setCriteria`

Set Criteria for the data validation rule

**Signature**

```typescript
setCriteria(type: DataValidationType, values: [DataValidationOperator, string, string], allowBlank = true): FDataValidation
```

**Parameters**

* `type` `DataValidationType` — *No description*
* `values` `[DataValidationOperator, string, string]` — *No description*
* `allowBlank` `boolean` *(optional)* — *No description*

**Returns**

* `FDataValidation` — The current instance for method chaining

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Create a new data validation rule that requires a number equal to 20 for the range A1:B10
const fRange = fWorksheet.getRange('A1:B10');
const rule = univerAPI.newDataValidation()
  .requireNumberEqualTo(20)
  .build();
fRange.setDataValidation(rule);

// Change the rule criteria to require a number between 1 and 10
fRange.getDataValidation().setCriteria(
  univerAPI.Enum.DataValidationType.DECIMAL,
  [univerAPI.Enum.DataValidationOperator.BETWEEN, '1', '10']
);
```

Source: 

`@univerjs/sheets-data-validation`

### `setOptions`

Sets the options for the data validation rule.

**Signature**

```typescript
setOptions(options: Partial<IDataValidationRuleOptions>): this
```

**Parameters**

* `options` `Partial<IDataValidationRuleOptions>` — *No description*

**Returns**

* `this` — The current instance for method chaining.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Create a new data validation rule that requires the user to enter a value from the list ['Yes', 'No'] for the range A1:B10
const fRange = fWorksheet.getRange('A1:B10');
const rule = univerAPI.newDataValidation()
  .requireValueInList(['Yes', 'No'])
  .setOptions({
    allowBlank: true,
    showErrorMessage: true,
    error: 'Please enter a value from the list'
  })
  .build();
fRange.setDataValidation(rule);
```

Source: 

`@univerjs/sheets-data-validation`

### `setRanges`

Set the ranges to the data validation rule

**Signature**

```typescript
setRanges(ranges: FRange[]): FDataValidation
```

**Parameters**

* `ranges` `FRange[]` — *No description*

**Returns**

* `FDataValidation` — The current instance for method chaining

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Create a new data validation rule that requires a number equal to 20 for the range A1:B10
const fRange = fWorksheet.getRange('A1:B10');
const rule = univerAPI.newDataValidation()
  .requireNumberEqualTo(20)
  .build();
fRange.setDataValidation(rule);

// Change the range to C1:D10
const newRuleRange = fWorksheet.getRange('C1:D10');
fRange.getDataValidation().setRanges([newRuleRange]);
```

Source: 

`@univerjs/sheets-data-validation`

### Actions & Operations

### `copy`

Creates a new instance of FDataValidationBuilder using the current rule object

**Signature**

```typescript
copy(): FDataValidationBuilder
```

**Returns**

* `FDataValidationBuilder` — A new FDataValidationBuilder instance with the same rule configuration

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
const fRange = fWorksheet.getRange('A1:B10');
const rule = univerAPI.newDataValidation()
  .requireNumberBetween(1, 10)
  .setOptions({
    allowBlank: true,
    showErrorMessage: true,
    error: 'Please enter a number between 1 and 10'
  })
  .build();
fRange.setDataValidation(rule);

const builder = fRange.getDataValidation().copy();
const newRule = builder
  .requireNumberBetween(1, 5)
  .setOptions({
    error: 'Please enter a number between 1 and 5'
  })
  .build();
fRange.setDataValidation(newRule);
```

Source: 

`@univerjs/sheets-data-validation`

### `delete`

Delete the data validation rule from the worksheet

**Signature**

```typescript
delete(): boolean
```

**Returns**

* `boolean` — true if the rule is deleted successfully, false otherwise

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Create a new data validation rule that requires a number equal to 20 for the range A1:B10
const fRange = fWorksheet.getRange('A1:B10');
const rule = univerAPI.newDataValidation()
  .requireNumberEqualTo(20)
  .build();
fRange.setDataValidation(rule);

// Delete the data validation rule
fRange.getDataValidation().delete();
```

Source: 

`@univerjs/sheets-data-validation`

### Miscellaneous

### `requireCheckbox`

Sets the data validation rule to require that the input is a boolean value; this value is rendered as a checkbox.

**Signature**

```typescript
requireCheckbox(checkedValue?: string, uncheckedValue?: string): FDataValidationBuilder
```

**Parameters**

* `checkedValue` `string` *(optional)* — *No description*
* `uncheckedValue` `string` *(optional)* — *No description*

**Returns**

* `FDataValidationBuilder` — The current instance for method chaining.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Set the data validation for cell A1:A10 to require a checkbox with default 1 and 0 values
const fRange = fWorksheet.getRange('A1:A10');
const rule = univerAPI.newDataValidation()
  .requireCheckbox()
  .build();
fRange.setDataValidation(rule);

// Set the data validation for cell B1:B10 to require a checkbox with 'Yes' and 'No' values
const fRange2 = fWorksheet.getRange('B1:B10');
const rule2 = univerAPI.newDataValidation()
  .requireCheckbox('Yes', 'No')
  .build();
fRange2.setDataValidation(rule2);
```

Source: 

`@univerjs/sheets-data-validation`

### `requireDateAfter`

Set the data validation type to DATE and configure the validation rules to be after a specific date.

**Signature**

```typescript
requireDateAfter(date: Date): FDataValidationBuilder
```

**Parameters**

* `date` `Date` — *No description*

**Returns**

* `FDataValidationBuilder` — The current instance for method chaining.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Set some date values in the range A1:B2
const fRange = fWorksheet.getRange('A1:B2');
fRange.setValues([
  ['2024-01-01', '2024-12-31'],
  ['2025-01-01', '2025-12-31']
]);

// Create a data validation rule that requires a date after 2025-01-01
const rule = univerAPI.newDataValidation()
  .requireDateAfter(new Date('2025-01-01'))
  .build();
fRange.setDataValidation(rule);

// Get the validation status of the range
const status = await fRange.getValidatorStatus();
console.log(status); // [['invalid', 'invalid'], ['invalid', 'valid']]
```

Source: 

`@univerjs/sheets-data-validation`

### `requireDateBefore`

Set the data validation type to DATE and configure the validation rules to be before a specific date.

**Signature**

```typescript
requireDateBefore(date: Date): FDataValidationBuilder
```

**Parameters**

* `date` `Date` — *No description*

**Returns**

* `FDataValidationBuilder` — The current instance for method chaining.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Set some date values in the range A1:B2
const fRange = fWorksheet.getRange('A1:B2');
fRange.setValues([
  ['2024-01-01', '2024-12-31'],
  ['2025-01-01', '2025-12-31']
]);

// Create a data validation rule that requires a date before 2025-01-01
const rule = univerAPI.newDataValidation()
  .requireDateBefore(new Date('2025-01-01'))
  .build();
fRange.setDataValidation(rule);

// Get the validation status of the range
const status = await fRange.getValidatorStatus();
console.log(status); // [['valid', 'valid'], ['invalid', 'invalid']]
```

Source: 

`@univerjs/sheets-data-validation`

### `requireDateBetween`

Set the data validation type to DATE and configure the validation rules to be within a specific date range.

**Signature**

```typescript
requireDateBetween(start: Date, end: Date): FDataValidationBuilder
```

**Parameters**

* `start` `Date` — *No description*
* `end` `Date` — *No description*

**Returns**

* `FDataValidationBuilder` — The current instance for method chaining.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Set some date values in the range A1:B2
const fRange = fWorksheet.getRange('A1:B2');
fRange.setValues([
  ['2024-01-01', '2024-12-31'],
  ['2025-01-01', '2025-12-31']
]);

// Create a data validation rule that requires a date between 2024-06-01 and 2025-06-01
const rule = univerAPI.newDataValidation()
  .requireDateBetween(new Date('2024-06-01'), new Date('2025-06-01'))
  .build();
fRange.setDataValidation(rule);

// Get the validation status of the range
const status = await fRange.getValidatorStatus();
console.log(status); // [['invalid', 'valid'], ['valid', 'invalid']]
```

Source: 

`@univerjs/sheets-data-validation`

### `requireDateEqualTo`

Set the data validation type to DATE and configure the validation rules to be equal to a specific date.

**Signature**

```typescript
requireDateEqualTo(date: Date): FDataValidationBuilder
```

**Parameters**

* `date` `Date` — *No description*

**Returns**

* `FDataValidationBuilder` — The current instance for method chaining.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Set some date values in the range A1:B2
const fRange = fWorksheet.getRange('A1:B2');
fRange.setValues([
  ['2024-01-01', '2024-12-31'],
  ['2025-01-01', '2025-12-31']
]);

// Create a data validation rule that requires a date equal to 2025-01-01
const rule = univerAPI.newDataValidation()
  .requireDateEqualTo(new Date('2025-01-01'))
  .build();
fRange.setDataValidation(rule);

// Get the validation status of the cell A2
const status = await fWorksheet.getRange('A2').getValidatorStatus();
console.log(status?.[0]?.[0]); // 'valid'

// Get the validation status of the cell B2
const status2 = await fWorksheet.getRange('B2').getValidatorStatus();
console.log(status2?.[0]?.[0]); // 'invalid'
```

Source: 

`@univerjs/sheets-data-validation`

### `requireDateNotBetween`

Set the data validation type to DATE and configure the validation rules to be not within a specific date range.

**Signature**

```typescript
requireDateNotBetween(start: Date, end: Date): FDataValidationBuilder
```

**Parameters**

* `start` `Date` — *No description*
* `end` `Date` — *No description*

**Returns**

* `FDataValidationBuilder` — The current instance for method chaining.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Set some date values in the range A1:B2
const fRange = fWorksheet.getRange('A1:B2');
fRange.setValues([
  ['2024-01-01', '2024-12-31'],
  ['2025-01-01', '2025-12-31']
]);

// Create a data validation rule that requires a date not between 2024-06-01 and 2025-06-01
const rule = univerAPI.newDataValidation()
  .requireDateNotBetween(new Date('2024-06-01'), new Date('2025-06-01'))
  .build();
fRange.setDataValidation(rule);

// Get the validation status of the range
const status = await fRange.getValidatorStatus();
console.log(status); // [['valid', 'invalid'], ['invalid', 'valid']]
```

Source: 

`@univerjs/sheets-data-validation`

### `requireDateOnOrAfter`

Set the data validation type to DATE and configure the validation rules to be on or after a specific date.

**Signature**

```typescript
requireDateOnOrAfter(date: Date): FDataValidationBuilder
```

**Parameters**

* `date` `Date` — *No description*

**Returns**

* `FDataValidationBuilder` — The current instance for method chaining.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Set some date values in the range A1:B2
const fRange = fWorksheet.getRange('A1:B2');
fRange.setValues([
  ['2024-01-01', '2024-12-31'],
  ['2025-01-01', '2025-12-31']
]);

// Create a data validation rule that requires a date on or after 2025-01-01
const rule = univerAPI.newDataValidation()
  .requireDateOnOrAfter(new Date('2025-01-01'))
  .build();
fRange.setDataValidation(rule);

// Get the validation status of the range
const status = await fRange.getValidatorStatus();
console.log(status); // [['invalid', 'invalid'], ['valid', 'valid']]
```

Source: 

`@univerjs/sheets-data-validation`

### `requireDateOnOrBefore`

Set the data validation type to DATE and configure the validation rules to be on or before a specific date.

**Signature**

```typescript
requireDateOnOrBefore(date: Date): FDataValidationBuilder
```

**Parameters**

* `date` `Date` — *No description*

**Returns**

* `FDataValidationBuilder` — The current instance for method chaining.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Set some date values in the range A1:B2
const fRange = fWorksheet.getRange('A1:B2');
fRange.setValues([
  ['2024-01-01', '2024-12-31'],
  ['2025-01-01', '2025-12-31']
]);

// Create a data validation rule that requires a date on or before 2025-01-01
const rule = univerAPI.newDataValidation()
  .requireDateOnOrBefore(new Date('2025-01-01'))
  .build();
fRange.setDataValidation(rule);

// Get the validation status of the range
const status = await fRange.getValidatorStatus();
console.log(status); // [['valid', 'valid'], ['valid', 'invalid']]
```

Source: 

`@univerjs/sheets-data-validation`

### `requireFormulaSatisfied`

Sets the data validation rule to require that the given formula evaluates to `true`.

**Signature**

```typescript
requireFormulaSatisfied(formula: string): FDataValidationBuilder
```

**Parameters**

* `formula` `string` — *No description*

**Returns**

* `FDataValidationBuilder` — The current instance for method chaining.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Set some values in the range A1:B2 and C1:D2
const cell = fWorksheet.getRange('A1:B2');
cell.setValues([
  [4, 3],
  [2, 1]
]);
const fRange = fWorksheet.getRange('C1:D2');
fRange.setValues([
  [1, 2],
  [3, 4]
]);

// Create a data validation rule that requires the formula '=A1>2' to be satisfied
const rule = univerAPI.newDataValidation()
  .requireFormulaSatisfied('=A1>2')
  .setOptions({
    showErrorMessage: true,
    error: 'Please enter a value greater than 2'
  })
  .build();
fRange.setDataValidation(rule);

// Get the validation status of the range
const status = await fRange.getValidatorStatus();
console.log(status); // [['valid', 'valid'], ['invalid', 'invalid']]
```

Source: 

`@univerjs/sheets-data-validation`

### `requireNumberBetween`

Sets the data validation rule to require a number that falls between, or is either of, two specified numbers.

**Signature**

```typescript
requireNumberBetween(start: number, end: number, isInteger?: boolean): FDataValidationBuilder
```

**Parameters**

* `start` `number` — *No description*
* `end` `number` — *No description*
* `isInteger` `boolean` *(optional)* — *No description*

**Returns**

* `FDataValidationBuilder` — The current instance for method chaining.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Create a new data validation rule that requires a number between 1 and 10 for the range A1:B10
const fRange = fWorksheet.getRange('A1:B10');
const rule = univerAPI.newDataValidation()
  .requireNumberBetween(1, 10)
  .setOptions({
    allowBlank: false,
    showErrorMessage: true,
    error: 'Please enter a number between 1 and 10'
  })
  .build();
fRange.setDataValidation(rule);
```

Source: 

`@univerjs/sheets-data-validation`

### `requireNumberEqualTo`

Sets the data validation rule to require a number equal to the given value.

**Signature**

```typescript
requireNumberEqualTo(num: number, isInteger?: boolean): FDataValidationBuilder
```

**Parameters**

* `num` `number` — *No description*
* `isInteger` `boolean` *(optional)* — *No description*

**Returns**

* `FDataValidationBuilder` — The current instance for method chaining.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Create a new data validation rule that requires a number equal to 10 for the range A1:B10
const fRange = fWorksheet.getRange('A1:B10');
const rule = univerAPI.newDataValidation()
  .requireNumberEqualTo(10)
  .setOptions({
    allowBlank: false,
    showErrorMessage: true,
    error: 'Please enter a number equal to 10'
  })
  .build();
fRange.setDataValidation(rule);
```

Source: 

`@univerjs/sheets-data-validation`

### `requireNumberGreaterThan`

Sets the data validation rule to require a number greater than the given value.

**Signature**

```typescript
requireNumberGreaterThan(num: number, isInteger?: boolean): FDataValidationBuilder
```

**Parameters**

* `num` `number` — *No description*
* `isInteger` `boolean` *(optional)* — *No description*

**Returns**

* `FDataValidationBuilder` — The current instance for method chaining.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Create a new data validation rule that requires a number greater than 10 for the range A1:B10
const fRange = fWorksheet.getRange('A1:B10');
const rule = univerAPI.newDataValidation()
  .requireNumberGreaterThan(10)
  .setOptions({
    allowBlank: false,
    showErrorMessage: true,
    error: 'Please enter a number greater than 10'
  })
  .build();
fRange.setDataValidation(rule);
```

Source: 

`@univerjs/sheets-data-validation`

### `requireNumberGreaterThanOrEqualTo`

Sets the data validation rule to require a number greater than or equal to the given value.

**Signature**

```typescript
requireNumberGreaterThanOrEqualTo(num: number, isInteger?: boolean): FDataValidationBuilder
```

**Parameters**

* `num` `number` — *No description*
* `isInteger` `boolean` *(optional)* — *No description*

**Returns**

* `FDataValidationBuilder` — The current instance for method chaining.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Create a new data validation rule that requires a number greater than 10 or equal to 10 for the range A1:B10
const fRange = fWorksheet.getRange('A1:B10');
const rule = univerAPI.newDataValidation()
  .requireNumberGreaterThanOrEqualTo(10)
  .setOptions({
    allowBlank: false,
    showErrorMessage: true,
    error: 'Please enter a number greater than 10 or equal to 10'
  })
  .build();
fRange.setDataValidation(rule);
```

Source: 

`@univerjs/sheets-data-validation`

### `requireNumberLessThan`

Sets the data validation rule to require a number less than the given value.

**Signature**

```typescript
requireNumberLessThan(num: number, isInteger?: boolean): FDataValidationBuilder
```

**Parameters**

* `num` `number` — *No description*
* `isInteger` `boolean` *(optional)* — *No description*

**Returns**

* `FDataValidationBuilder` — The current instance for method chaining.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Create a new data validation rule that requires a number less than 10 for the range A1:B10
const fRange = fWorksheet.getRange('A1:B10');
const rule = univerAPI.newDataValidation()
  .requireNumberLessThan(10)
  .setOptions({
    allowBlank: false,
    showErrorMessage: true,
    error: 'Please enter a number less than 10'
  })
  .build();
fRange.setDataValidation(rule);
```

Source: 

`@univerjs/sheets-data-validation`

### `requireNumberLessThanOrEqualTo`

Sets the data validation rule to require a number less than or equal to the given value.

**Signature**

```typescript
requireNumberLessThanOrEqualTo(num: number, isInteger?: boolean): FDataValidationBuilder
```

**Parameters**

* `num` `number` — *No description*
* `isInteger` `boolean` *(optional)* — *No description*

**Returns**

* `FDataValidationBuilder` — The current instance for method chaining.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Create a new data validation rule that requires a number less than 10 or equal to 10 for the range A1:B10
const fRange = fWorksheet.getRange('A1:B10');
const rule = univerAPI.newDataValidation()
  .requireNumberLessThanOrEqualTo(10)
  .setOptions({
    allowBlank: false,
    showErrorMessage: true,
    error: 'Please enter a number less than 10 or equal to 10'
  })
  .build();
fRange.setDataValidation(rule);
```

Source: 

`@univerjs/sheets-data-validation`

### `requireNumberNotBetween`

Sets the data validation rule to require a number that does not fall between, and is neither of, two specified numbers.

**Signature**

```typescript
requireNumberNotBetween(start: number, end: number, isInteger?: boolean): FDataValidationBuilder
```

**Parameters**

* `start` `number` — *No description*
* `end` `number` — *No description*
* `isInteger` `boolean` *(optional)* — *No description*

**Returns**

* `FDataValidationBuilder` — The current instance for method chaining.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Create a new data validation rule that requires a number not between 1 and 10 for the range A1:B10
const fRange = fWorksheet.getRange('A1:B10');
const rule = univerAPI.newDataValidation()
  .requireNumberNotBetween(1, 10)
  .setOptions({
    allowBlank: false,
    showErrorMessage: true,
    error: 'Please enter a number not between 1 and 10'
  })
  .build();
fRange.setDataValidation(rule);
```

Source: 

`@univerjs/sheets-data-validation`

### `requireNumberNotEqualTo`

Sets the data validation rule to require a number not equal to the given value.

**Signature**

```typescript
requireNumberNotEqualTo(num: number, isInteger?: boolean): FDataValidationBuilder
```

**Parameters**

* `num` `number` — *No description*
* `isInteger` `boolean` *(optional)* — *No description*

**Returns**

* `FDataValidationBuilder` — The current instance for method chaining.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Create a new data validation rule that requires a number not equal to 10 for the range A1:B10
const fRange = fWorksheet.getRange('A1:B10');
const rule = univerAPI.newDataValidation()
  .requireNumberNotEqualTo(10)
  .setOptions({
    allowBlank: false,
    showErrorMessage: true,
    error: 'Please enter a number not equal to 10'
  })
  .build();
fRange.setDataValidation(rule);
```

Source: 

`@univerjs/sheets-data-validation`

### `requireValueInList`

Sets a data validation rule that requires the user to enter a value from a list of specific values.
The list can be displayed in a dropdown, and the user can choose multiple values according to the settings.

**Signature**

```typescript
requireValueInList(values: string[], multiple?: boolean, showDropdown?: boolean): FDataValidationBuilder
```

**Parameters**

* `values` `string[]` — *No description*
* `multiple` `boolean` *(optional)* — *No description*
* `showDropdown` `boolean` *(optional)* — *No description*

**Returns**

* `FDataValidationBuilder` — The current instance for method chaining.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Create a new data validation rule that requires the user to enter a value from the list ['Yes', 'No'] for the range A1:B10
const fRange = fWorksheet.getRange('A1:B10');
const rule = univerAPI.newDataValidation()
  .requireValueInList(['Yes', 'No'])
  .setOptions({
    allowBlank: true,
    showErrorMessage: true,
    error: 'Please enter a value from the list'
  })
  .build();
fRange.setDataValidation(rule);
```

Source: 

`@univerjs/sheets-data-validation`

### `requireValueInRange`

Sets a data validation rule that requires the user to enter a value within a specific range.
The range is defined by an FRange object, which contains the unit ID, sheet name, and cell range.

**Signature**

```typescript
requireValueInRange(range: FRange, multiple?: boolean, showDropdown?: boolean): FDataValidationBuilder
```

**Parameters**

* `range` `FRange` — *No description*
* `multiple` `boolean` *(optional)* — *No description*
* `showDropdown` `boolean` *(optional)* — *No description*

**Returns**

* `FDataValidationBuilder` — The current instance for method chaining.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Set the values in the range B1:B2
const fRange = fWorksheet.getRange('B1:B2');
fRange.setValues([
  ['Yes'],
  ['No']
]);

// Create a new data validation rule that requires the user to enter a value from the range B1:B2 for the range A1:A10
const rule = univerAPI.newDataValidation()
  .requireValueInRange(fRange)
  .setOptions({
    allowBlank: false,
    showErrorMessage: true,
    error: 'Please enter a value from the list'
  })
  .build();
const cell = fWorksheet.getRange('A1');
cell.setDataValidation(rule);
```

Source: 

`@univerjs/sheets-data-validation`

### `rule`

**Signature**

```typescript
rule: IDataValidationRule
```

**Returns**

* `IDataValidationRule` — See signature above.

Source: 

`@univerjs/sheets-data-validation`
