@univerjs/sheets-data-validation v0.5.4


Class: FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:30

Builder for data validation rules.

Set the data validation for cell A1 to require a value from B1:B10.
var rule = FUniver.newDataValidation().requireValueInRange(range).build();
cell.setDataValidation(rule);

Constructors

new FDataValidationBuilder()

new FDataValidationBuilder(rule?): FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:33

Parameters

ParameterType
rule?IDataValidationRule

Returns

FDataValidationBuilder

Methods

build()

build(): FDataValidation

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:45

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

Returns

FDataValidation

A new instance of the FDataValidation class


copy()

copy(): FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:53

Creates a duplicate of the current DataValidationBuilder object

Returns

FDataValidationBuilder

A new instance of the DataValidationBuilder class


getAllowInvalid()

getAllowInvalid(): boolean

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:64

Determines whether invalid data is allowed

Returns

boolean

True if invalid data is allowed, False otherwise


getCriteriaType()

getCriteriaType(): string

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:72

Gets the data validation type of the rule

Returns

string

The data validation type


getCriteriaValues()

getCriteriaValues(): [undefined | string, undefined | string, undefined | string]

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:80

Gets the values used for criteria evaluation

Returns

[undefined | string, undefined | string, undefined | string]

An array containing the operator, formula1, and formula2 values


getHelpText()

getHelpText(): undefined | string

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:88

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

Returns

undefined | string

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


requireCheckbox()

requireCheckbox(checkedValue?, uncheckedValue?): FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:98

Sets the data validation type to CHECKBOX and sets the checked and unchecked values

Parameters

ParameterTypeDescription
checkedValue?stringThe value when the checkbox is checked (Optional)
uncheckedValue?stringThe value when the checkbox is unchecked (Optional)

Returns

FDataValidationBuilder

The current instance of the FDataValidationBuilder class to allow for method chaining


requireDateAfter()

requireDateAfter(date): FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:111

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

Parameters

ParameterTypeDescription
dateDateThe date to compare against. The formatted date string will be set as formula1

Returns

FDataValidationBuilder

The current instance of the FDataValidationBuilder class to allow for method chaining


requireDateBefore()

requireDateBefore(date): FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:124

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

Parameters

ParameterTypeDescription
dateDateThe date to compare against. The formatted date string will be set as formula1

Returns

FDataValidationBuilder

The current instance of the FDataValidationBuilder class to allow for method chaining


requireDateBetween()

requireDateBetween(start, end): FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:139

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

Parameters

ParameterTypeDescription
startDateThe starting date of the range. The formatted date string will be set as formula1
endDateThe ending date of the range. The formatted date string will be set as formula2

Returns

FDataValidationBuilder

The current instance of the FDataValidationBuilder class to allow for method chaining


requireDateEqualTo()

requireDateEqualTo(date): FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:153

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

Parameters

ParameterTypeDescription
dateDateThe date to compare against. The formatted date string will be set as formula1

Returns

FDataValidationBuilder

The current instance of the FDataValidationBuilder class to allow for method chaining


requireDateNotBetween()

requireDateNotBetween(start, end): FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:168

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

Parameters

ParameterTypeDescription
startDateThe starting date of the date range
endDateThe ending date of the date range

Returns

FDataValidationBuilder

The current instance of the FDataValidationBuilder class to allow for method chaining


requireDateOnOrAfter()

requireDateOnOrAfter(date): FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:182

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

Parameters

ParameterTypeDescription
dateDateThe date to compare against. The formatted date string will be set as formula1

Returns

FDataValidationBuilder

The current instance of the FDataValidationBuilder class to allow for method chaining


requireDateOnOrBefore()

requireDateOnOrBefore(date): FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:196

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

Parameters

ParameterTypeDescription
dateDateThe date to compare against. The formatted date string will be set as formula1

Returns

FDataValidationBuilder

The current instance of the FDataValidationBuilder class to allow for method chaining


requireFormulaSatisfied()

requireFormulaSatisfied(formula): FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:211

Requires that a custom formula be satisfied. Sets the data validation type to CUSTOM and configures the validation rule based on the provided formula string.

Parameters

ParameterTypeDescription
formulastringThe formula string that needs to be satisfied.

Returns

FDataValidationBuilder

The current instance of the FDataValidationBuilder class to allow for method chaining.


requireNumberBetween()

requireNumberBetween(
   start, 
   end, 
   isInteger?): FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:226

Requires the user to enter a number within a specific range, which can be integer or decimal. Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number range.

Parameters

ParameterTypeDescription
startnumberThe starting value of the number range.
endnumberThe ending value of the number range.
isInteger?booleanIndicates whether the required number is an integer. Default is undefined, meaning it can be an integer or decimal.

Returns

FDataValidationBuilder

The current instance of the FDataValidationBuilder class to allow for method chaining.


requireNumberEqualTo()

requireNumberEqualTo(num, isInteger?): FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:242

Requires the user to enter a number that is equal to a specific value, which can be an integer or a decimal. Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number.

Parameters

ParameterTypeDescription
numnumberThe number to which the entered number should be equal.
isInteger?booleanIndicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal.

Returns

FDataValidationBuilder

The current instance of the FDataValidationBuilder class to allow for method chaining.


requireNumberGreaterThan()

requireNumberGreaterThan(num, isInteger?): FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:257

Requires the user to enter a number that is greater than a specific value, which can be an integer or a decimal. Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number.

Parameters

ParameterTypeDescription
numnumberThe number to which the entered number should be greater.
isInteger?booleanIndicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal.

Returns

FDataValidationBuilder

The current instance of the FDataValidationBuilder class to allow for method chaining.


requireNumberGreaterThanOrEqualTo()

requireNumberGreaterThanOrEqualTo(num, isInteger?): FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:272

Requires the user to enter a number that is greater than or equal to a specific value, which can be an integer or a decimal. Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number.

Parameters

ParameterTypeDescription
numnumberThe number to which the entered number should be greater than or equal.
isInteger?booleanIndicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal.

Returns

FDataValidationBuilder

The current instance of the FDataValidationBuilder class to allow for method chaining.


requireNumberLessThan()

requireNumberLessThan(num, isInteger?): FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:287

Requires the user to enter a number that is less than a specific value, which can be an integer or a decimal. Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number.

Parameters

ParameterTypeDescription
numnumberThe number to which the entered number should be less.
isInteger?booleanIndicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal.

Returns

FDataValidationBuilder

The current instance of the FDataValidationBuilder class to allow for method chaining.


requireNumberLessThanOrEqualTo()

requireNumberLessThanOrEqualTo(num, isInteger?): FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:302

Sets the data validation rule to require a number less than or equal to a specified value The specified value can be an integer or a decimal

Parameters

ParameterTypeDescription
numnumberThe number to which the entered number should be less than or equal
isInteger?booleanIndicates whether the required number is an integer

Returns

FDataValidationBuilder

The current instance of the DataValidationBuilder class, allowing for method chaining


requireNumberNotBetween()

requireNumberNotBetween(
   start, 
   end, 
   isInteger?): FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:318

Sets a data validation rule that requires the user to enter a number outside a specified range The specified range includes all integers and decimals

Parameters

ParameterTypeDescription
startnumberThe starting point of the specified range
endnumberThe end point of the specified range
isInteger?booleanOptional parameter, indicating whether the number to be verified is an integer. Default value is false

Returns

FDataValidationBuilder

An instance of the FDataValidationBuilder class, allowing for method chaining


requireNumberNotEqualTo()

requireNumberNotEqualTo(num, isInteger?): FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:334

Creates a data validation rule that requires the user to enter a number that is not equal to a specific value The specific value can be an integer or a decimal

Parameters

ParameterTypeDescription
numnumberThe number to which the entered number should not be equal
isInteger?booleanIndicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal

Returns

FDataValidationBuilder

The current instance of the FDataValidationBuilder class to allow for method chaining


requireValueInList()

requireValueInList(
   values, 
   multiple?, 
   showDropdown?): FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:350

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.

Parameters

ParameterTypeDescription
valuesstring[]An array containing the specific values that the user can enter.
multiple?booleanOptional parameter indicating whether the user can select multiple values. Default is false, meaning only one value can be selected.
showDropdown?booleanOptional parameter indicating whether to display the list in a dropdown. Default is true, meaning the list will be displayed as a dropdown.

Returns

FDataValidationBuilder

An instance of the FDataValidationBuilder class, allowing for method chaining.


requireValueInRange()

requireValueInRange(
   range, 
   multiple?, 
   showDropdown?): FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:367

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.

Parameters

ParameterTypeDescription
rangeFRangeAn FRange object representing the range of values that the user can enter.
multiple?booleanOptional parameter indicating whether the user can select multiple values. Default is false, meaning only one value can be selected.
showDropdown?booleanOptional parameter indicating whether to display the list in a dropdown. Default is true, meaning the list will be displayed as a dropdown.

Returns

FDataValidationBuilder

The current instance of the FDataValidationBuilder class to allow for method chaining.


setAllowBlank()

setAllowBlank(allowBlank): FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:421

Parameters

ParameterType
allowBlankboolean

Returns

FDataValidationBuilder


setAllowInvalid()

setAllowInvalid(allowInvalidData): FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:387

Sets whether to allow invalid data and configures the error style for data validation. 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.

Parameters

ParameterTypeDescription
allowInvalidDatabooleanA boolean value indicating whether to allow invalid data.

Returns

FDataValidationBuilder

The current instance of the FDataValidationBuilder class to allow for method chaining.


setHelpText()

setHelpText(helpText): FDataValidationBuilder

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:398

Sets the help text and enables the display of error messages for data validation. This method allows you to set a custom help text that will be displayed when the user enters invalid data.

Parameters

ParameterTypeDescription
helpTextstringThe text to display as help information.

Returns

FDataValidationBuilder

The current instance of the FDataValidationBuilder class to allow for method chaining.


setOptions()

setOptions(options): this

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:432

Sets the options for the data validation rule. For details of options, please refer to https://univer.ai/typedoc/@univerjs/core/interfaces/IDataValidationRuleOptions

Parameters

ParameterTypeDescription
optionsPartial<IDataValidationRuleOptions>The options to set for the data validation rule.

Returns

this

The current instance of the FDataValidationBuilder class to allow for method chaining.


withCriteriaValues()

withCriteriaValues(type, values): this

Defined in: sheets-data-validation/src/facade/f-data-validation-builder.ts:413

Sets the criteria values for data validation. This method is used to configure the validation rules based on specific criteria values.

Parameters

ParameterTypeDescription
typestringThe type of data validation.
values[DataValidationOperator, string, string]An array containing the criteria values. The array should have three elements: [operator, formula1, formula2]. operator is a DataValidationOperator enum value, formula1 is the first formula, and formula2 is the second formula.

Returns

this

The current instance of the FDataValidationBuilder class, allowing for method chaining.