@univerjs/sheets-data-validation 0.5.3-nightly.202501121605 → 0.5.4-nightly.202501131606
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/facade.js
CHANGED
|
@@ -18,7 +18,6 @@ class D {
|
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Builds an FDataValidation instance based on the _rule property of the current class
|
|
21
|
-
*
|
|
22
21
|
* @returns {FDataValidation} A new instance of the FDataValidation class
|
|
23
22
|
*/
|
|
24
23
|
build() {
|
|
@@ -26,8 +25,7 @@ class D {
|
|
|
26
25
|
}
|
|
27
26
|
/**
|
|
28
27
|
* Creates a duplicate of the current DataValidationBuilder object
|
|
29
|
-
*
|
|
30
|
-
* @return {FDataValidationBuilder} A new instance of the DataValidationBuilder class
|
|
28
|
+
* @returns {FDataValidationBuilder} A new instance of the DataValidationBuilder class
|
|
31
29
|
*/
|
|
32
30
|
copy() {
|
|
33
31
|
return new D({
|
|
@@ -37,7 +35,6 @@ class D {
|
|
|
37
35
|
}
|
|
38
36
|
/**
|
|
39
37
|
* Determines whether invalid data is allowed
|
|
40
|
-
*
|
|
41
38
|
* @returns {boolean} True if invalid data is allowed, False otherwise
|
|
42
39
|
*/
|
|
43
40
|
getAllowInvalid() {
|
|
@@ -45,7 +42,6 @@ class D {
|
|
|
45
42
|
}
|
|
46
43
|
/**
|
|
47
44
|
* Gets the data validation type of the rule
|
|
48
|
-
*
|
|
49
45
|
* @returns {DataValidationType} The data validation type
|
|
50
46
|
*/
|
|
51
47
|
getCriteriaType() {
|
|
@@ -53,7 +49,6 @@ class D {
|
|
|
53
49
|
}
|
|
54
50
|
/**
|
|
55
51
|
* Gets the values used for criteria evaluation
|
|
56
|
-
*
|
|
57
52
|
* @returns {[string, string, string]} An array containing the operator, formula1, and formula2 values
|
|
58
53
|
*/
|
|
59
54
|
getCriteriaValues() {
|
|
@@ -61,7 +56,6 @@ class D {
|
|
|
61
56
|
}
|
|
62
57
|
/**
|
|
63
58
|
* Gets the help text information, which is used to provide users with guidance and support
|
|
64
|
-
*
|
|
65
59
|
* @returns {string | undefined} Returns the help text information. If there is no error message, it returns an undefined value.
|
|
66
60
|
*/
|
|
67
61
|
getHelpText() {
|
|
@@ -69,7 +63,6 @@ class D {
|
|
|
69
63
|
}
|
|
70
64
|
/**
|
|
71
65
|
* Sets the data validation type to CHECKBOX and sets the checked and unchecked values
|
|
72
|
-
*
|
|
73
66
|
* @param checkedValue The value when the checkbox is checked (Optional)
|
|
74
67
|
* @param uncheckedValue The value when the checkbox is unchecked (Optional)
|
|
75
68
|
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
@@ -79,65 +72,58 @@ class D {
|
|
|
79
72
|
}
|
|
80
73
|
/**
|
|
81
74
|
* Set the data validation type to DATE and configure the validation rules to be after a specific date
|
|
82
|
-
*
|
|
83
75
|
* @param date The date to compare against. The formatted date string will be set as formula1
|
|
84
|
-
* @
|
|
76
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
85
77
|
*/
|
|
86
78
|
requireDateAfter(e) {
|
|
87
79
|
return this._rule.type = o.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.operator = d.GREATER_THAN, this;
|
|
88
80
|
}
|
|
89
81
|
/**
|
|
90
82
|
* Set the data validation type to DATE and configure the validation rules to be before a specific date
|
|
91
|
-
*
|
|
92
83
|
* @param date The date to compare against. The formatted date string will be set as formula1
|
|
93
|
-
* @
|
|
84
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
94
85
|
*/
|
|
95
86
|
requireDateBefore(e) {
|
|
96
87
|
return this._rule.type = o.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = d.LESS_THAN, this;
|
|
97
88
|
}
|
|
98
89
|
/**
|
|
99
90
|
* Set the data validation type to DATE and configure the validation rules to be within a specific date range
|
|
100
|
-
*
|
|
101
91
|
* @param start The starting date of the range. The formatted date string will be set as formula1
|
|
102
92
|
* @param end The ending date of the range. The formatted date string will be set as formula2
|
|
103
|
-
* @
|
|
93
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
104
94
|
*/
|
|
105
95
|
requireDateBetween(e, t) {
|
|
106
96
|
return this._rule.type = o.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = t.toLocaleDateString(), this._rule.operator = d.BETWEEN, this;
|
|
107
97
|
}
|
|
108
98
|
/**
|
|
109
99
|
* Set the data validation type to DATE and configure the validation rules to be equal to a specific date
|
|
110
|
-
*
|
|
111
100
|
* @param date The date to compare against. The formatted date string will be set as formula1
|
|
112
|
-
* @
|
|
101
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
113
102
|
*/
|
|
114
103
|
requireDateEqualTo(e) {
|
|
115
104
|
return this._rule.type = o.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = d.EQUAL, this;
|
|
116
105
|
}
|
|
117
106
|
/**
|
|
118
107
|
* Set the data validation type to DATE and configure the validation rules to be not within a specific date range
|
|
119
|
-
*
|
|
120
108
|
* @param start The starting date of the date range
|
|
121
109
|
* @param end The ending date of the date range
|
|
122
|
-
* @
|
|
110
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
123
111
|
*/
|
|
124
112
|
requireDateNotBetween(e, t) {
|
|
125
113
|
return this._rule.type = o.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = t.toLocaleDateString(), this._rule.operator = d.NOT_BETWEEN, this;
|
|
126
114
|
}
|
|
127
115
|
/**
|
|
128
116
|
* Set the data validation type to DATE and configure the validation rules to be on or after a specific date
|
|
129
|
-
*
|
|
130
117
|
* @param date The date to compare against. The formatted date string will be set as formula1
|
|
131
|
-
* @
|
|
118
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
132
119
|
*/
|
|
133
120
|
requireDateOnOrAfter(e) {
|
|
134
121
|
return this._rule.type = o.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = d.GREATER_THAN_OR_EQUAL, this;
|
|
135
122
|
}
|
|
136
123
|
/**
|
|
137
124
|
* Set the data validation type to DATE and configure the validation rules to be on or before a specific date
|
|
138
|
-
*
|
|
139
125
|
* @param date The date to compare against. The formatted date string will be set as formula1
|
|
140
|
-
* @
|
|
126
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
141
127
|
*/
|
|
142
128
|
requireDateOnOrBefore(e) {
|
|
143
129
|
return this._rule.type = o.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = d.LESS_THAN_OR_EQUAL, this;
|
|
@@ -145,9 +131,8 @@ class D {
|
|
|
145
131
|
/**
|
|
146
132
|
* Requires that a custom formula be satisfied.
|
|
147
133
|
* Sets the data validation type to CUSTOM and configures the validation rule based on the provided formula string.
|
|
148
|
-
*
|
|
149
134
|
* @param formula The formula string that needs to be satisfied.
|
|
150
|
-
* @
|
|
135
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
151
136
|
*/
|
|
152
137
|
requireFormulaSatisfied(e) {
|
|
153
138
|
return this._rule.type = o.CUSTOM, this._rule.formula1 = e, this._rule.formula2 = void 0, this;
|
|
@@ -155,11 +140,10 @@ class D {
|
|
|
155
140
|
/**
|
|
156
141
|
* Requires the user to enter a number within a specific range, which can be integer or decimal.
|
|
157
142
|
* Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number range.
|
|
158
|
-
*
|
|
159
143
|
* @param start The starting value of the number range.
|
|
160
144
|
* @param end The ending value of the number range.
|
|
161
145
|
* @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or decimal.
|
|
162
|
-
* @
|
|
146
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
163
147
|
*/
|
|
164
148
|
requireNumberBetween(e, t, r) {
|
|
165
149
|
return this._rule.formula1 = `${e}`, this._rule.formula2 = `${t}`, this._rule.operator = d.BETWEEN, this._rule.type = r ? o.WHOLE : o.DECIMAL, this;
|
|
@@ -167,10 +151,9 @@ class D {
|
|
|
167
151
|
/**
|
|
168
152
|
* Requires the user to enter a number that is equal to a specific value, which can be an integer or a decimal.
|
|
169
153
|
* Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number.
|
|
170
|
-
*
|
|
171
154
|
* @param num The number to which the entered number should be equal.
|
|
172
155
|
* @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal.
|
|
173
|
-
* @
|
|
156
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
174
157
|
*/
|
|
175
158
|
requireNumberEqualTo(e, t) {
|
|
176
159
|
return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = d.EQUAL, this._rule.type = t ? o.WHOLE : o.DECIMAL, this;
|
|
@@ -178,10 +161,9 @@ class D {
|
|
|
178
161
|
/**
|
|
179
162
|
* Requires the user to enter a number that is greater than a specific value, which can be an integer or a decimal.
|
|
180
163
|
* Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number.
|
|
181
|
-
*
|
|
182
164
|
* @param num The number to which the entered number should be greater.
|
|
183
165
|
* @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal.
|
|
184
|
-
* @
|
|
166
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
185
167
|
*/
|
|
186
168
|
requireNumberGreaterThan(e, t) {
|
|
187
169
|
return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = d.GREATER_THAN, this._rule.type = t ? o.WHOLE : o.DECIMAL, this;
|
|
@@ -189,10 +171,9 @@ class D {
|
|
|
189
171
|
/**
|
|
190
172
|
* 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.
|
|
191
173
|
* Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number.
|
|
192
|
-
*
|
|
193
174
|
* @param num The number to which the entered number should be greater than or equal.
|
|
194
175
|
* @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal.
|
|
195
|
-
* @
|
|
176
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
196
177
|
*/
|
|
197
178
|
requireNumberGreaterThanOrEqualTo(e, t) {
|
|
198
179
|
return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = d.GREATER_THAN_OR_EQUAL, this._rule.type = t ? o.WHOLE : o.DECIMAL, this;
|
|
@@ -200,10 +181,9 @@ class D {
|
|
|
200
181
|
/**
|
|
201
182
|
* Requires the user to enter a number that is less than a specific value, which can be an integer or a decimal.
|
|
202
183
|
* Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number.
|
|
203
|
-
*
|
|
204
184
|
* @param num The number to which the entered number should be less.
|
|
205
185
|
* @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal.
|
|
206
|
-
* @
|
|
186
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
207
187
|
*/
|
|
208
188
|
requireNumberLessThan(e, t) {
|
|
209
189
|
return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = d.LESS_THAN, this._rule.type = t ? o.WHOLE : o.DECIMAL, this;
|
|
@@ -211,10 +191,9 @@ class D {
|
|
|
211
191
|
/**
|
|
212
192
|
* Sets the data validation rule to require a number less than or equal to a specified value
|
|
213
193
|
* The specified value can be an integer or a decimal
|
|
214
|
-
*
|
|
215
194
|
* @param num The number to which the entered number should be less than or equal
|
|
216
195
|
* @param isInteger Indicates whether the required number is an integer
|
|
217
|
-
* @
|
|
196
|
+
* @returns The current instance of the DataValidationBuilder class, allowing for method chaining
|
|
218
197
|
*/
|
|
219
198
|
requireNumberLessThanOrEqualTo(e, t) {
|
|
220
199
|
return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = d.LESS_THAN_OR_EQUAL, this._rule.type = t ? o.WHOLE : o.DECIMAL, this;
|
|
@@ -222,11 +201,10 @@ class D {
|
|
|
222
201
|
/**
|
|
223
202
|
* Sets a data validation rule that requires the user to enter a number outside a specified range
|
|
224
203
|
* The specified range includes all integers and decimals
|
|
225
|
-
*
|
|
226
204
|
* @param start The starting point of the specified range
|
|
227
205
|
* @param end The end point of the specified range
|
|
228
206
|
* @param isInteger Optional parameter, indicating whether the number to be verified is an integer. Default value is false
|
|
229
|
-
* @
|
|
207
|
+
* @returns An instance of the FDataValidationBuilder class, allowing for method chaining
|
|
230
208
|
*/
|
|
231
209
|
requireNumberNotBetween(e, t, r) {
|
|
232
210
|
return this._rule.formula1 = `${e}`, this._rule.formula2 = `${t}`, this._rule.operator = d.NOT_BETWEEN, this._rule.type = r ? o.WHOLE : o.DECIMAL, this;
|
|
@@ -234,10 +212,9 @@ class D {
|
|
|
234
212
|
/**
|
|
235
213
|
* Creates a data validation rule that requires the user to enter a number that is not equal to a specific value
|
|
236
214
|
* The specific value can be an integer or a decimal
|
|
237
|
-
*
|
|
238
215
|
* @param num The number to which the entered number should not be equal
|
|
239
216
|
* @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal
|
|
240
|
-
* @
|
|
217
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
241
218
|
*/
|
|
242
219
|
requireNumberNotEqualTo(e, t) {
|
|
243
220
|
return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = d.NOT_EQUAL, this._rule.type = t ? o.WHOLE : o.DECIMAL, this;
|
|
@@ -245,11 +222,10 @@ class D {
|
|
|
245
222
|
/**
|
|
246
223
|
* Sets a data validation rule that requires the user to enter a value from a list of specific values.
|
|
247
224
|
* The list can be displayed in a dropdown, and the user can choose multiple values according to the settings.
|
|
248
|
-
*
|
|
249
225
|
* @param values An array containing the specific values that the user can enter.
|
|
250
226
|
* @param multiple Optional parameter indicating whether the user can select multiple values. Default is false, meaning only one value can be selected.
|
|
251
227
|
* @param showDropdown Optional parameter indicating whether to display the list in a dropdown. Default is true, meaning the list will be displayed as a dropdown.
|
|
252
|
-
* @
|
|
228
|
+
* @returns An instance of the FDataValidationBuilder class, allowing for method chaining.
|
|
253
229
|
*/
|
|
254
230
|
requireValueInList(e, t, r) {
|
|
255
231
|
return this._rule.type = t ? o.LIST_MULTIPLE : o.LIST, this._rule.formula1 = e.join(","), this._rule.formula2 = void 0, this._rule.showDropDown = r != null ? r : !0, this;
|
|
@@ -257,11 +233,10 @@ class D {
|
|
|
257
233
|
/**
|
|
258
234
|
* Sets a data validation rule that requires the user to enter a value within a specific range.
|
|
259
235
|
* The range is defined by an FRange object, which contains the unit ID, sheet name, and cell range.
|
|
260
|
-
*
|
|
261
236
|
* @param range An FRange object representing the range of values that the user can enter.
|
|
262
237
|
* @param multiple Optional parameter indicating whether the user can select multiple values. Default is false, meaning only one value can be selected.
|
|
263
238
|
* @param showDropdown Optional parameter indicating whether to display the list in a dropdown. Default is true, meaning the list will be displayed as a dropdown.
|
|
264
|
-
* @
|
|
239
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
265
240
|
*/
|
|
266
241
|
requireValueInRange(e, t, r) {
|
|
267
242
|
return this._rule.type = t ? o.LIST_MULTIPLE : o.LIST, this._rule.formula1 = `=${P({
|
|
@@ -274,9 +249,8 @@ class D {
|
|
|
274
249
|
* Sets whether to allow invalid data and configures the error style for data validation.
|
|
275
250
|
* If invalid data is not allowed, the error style will be set to STOP, indicating that data entry must stop upon encountering an error.
|
|
276
251
|
* 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.
|
|
277
|
-
*
|
|
278
252
|
* @param allowInvalidData A boolean value indicating whether to allow invalid data.
|
|
279
|
-
* @
|
|
253
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
280
254
|
*/
|
|
281
255
|
setAllowInvalid(e) {
|
|
282
256
|
return this._rule.errorStyle = e ? w.WARNING : w.STOP, this;
|
|
@@ -284,9 +258,8 @@ class D {
|
|
|
284
258
|
/**
|
|
285
259
|
* Sets the help text and enables the display of error messages for data validation.
|
|
286
260
|
* This method allows you to set a custom help text that will be displayed when the user enters invalid data.
|
|
287
|
-
*
|
|
288
261
|
* @param helpText The text to display as help information.
|
|
289
|
-
* @
|
|
262
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
290
263
|
*/
|
|
291
264
|
setHelpText(e) {
|
|
292
265
|
return this._rule.error = e, this._rule.showErrorMessage = !0, this;
|
|
@@ -294,12 +267,11 @@ class D {
|
|
|
294
267
|
/**
|
|
295
268
|
* Sets the criteria values for data validation.
|
|
296
269
|
* This method is used to configure the validation rules based on specific criteria values.
|
|
297
|
-
*
|
|
298
270
|
* @param type The type of data validation.
|
|
299
271
|
* @param values An array containing the criteria values.
|
|
300
272
|
* The array should have three elements: [operator, formula1, formula2].
|
|
301
273
|
* operator is a DataValidationOperator enum value, formula1 is the first formula, and formula2 is the second formula.
|
|
302
|
-
* @
|
|
274
|
+
* @returns The current instance of the FDataValidationBuilder class, allowing for method chaining.
|
|
303
275
|
*/
|
|
304
276
|
withCriteriaValues(e, t) {
|
|
305
277
|
return this._rule.type = e, this._rule.operator = t[0], this._rule.formula1 = t[1], this._rule.formula2 = t[2], this;
|
|
@@ -310,7 +282,6 @@ class D {
|
|
|
310
282
|
/**
|
|
311
283
|
* Sets the options for the data validation rule.
|
|
312
284
|
* For details of options, please refer to https://univer.ai/typedoc/@univerjs/core/interfaces/IDataValidationRuleOptions
|
|
313
|
-
*
|
|
314
285
|
* @param options The options to set for the data validation rule.
|
|
315
286
|
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
316
287
|
*/
|
|
@@ -327,15 +298,13 @@ class m {
|
|
|
327
298
|
}
|
|
328
299
|
/**
|
|
329
300
|
* Gets whether invalid data is allowed based on the error style value.
|
|
330
|
-
*
|
|
331
|
-
* @return true if invalid data is allowed, false otherwise.
|
|
301
|
+
* @returns true if invalid data is allowed, false otherwise.
|
|
332
302
|
*/
|
|
333
303
|
getAllowInvalid() {
|
|
334
304
|
return this.rule.errorStyle !== w.STOP;
|
|
335
305
|
}
|
|
336
306
|
/**
|
|
337
307
|
* Gets the data validation type of the rule
|
|
338
|
-
*
|
|
339
308
|
* @returns The data validation type
|
|
340
309
|
*/
|
|
341
310
|
getCriteriaType() {
|
|
@@ -343,7 +312,6 @@ class m {
|
|
|
343
312
|
}
|
|
344
313
|
/**
|
|
345
314
|
* Gets the values used for criteria evaluation
|
|
346
|
-
*
|
|
347
315
|
* @returns An array containing the operator, formula1, and formula2 values
|
|
348
316
|
*/
|
|
349
317
|
getCriteriaValues() {
|
|
@@ -351,7 +319,6 @@ class m {
|
|
|
351
319
|
}
|
|
352
320
|
/**
|
|
353
321
|
* Gets the help text information, which is used to provide users with guidance and support
|
|
354
|
-
*
|
|
355
322
|
* @returns Returns the help text information. If there is no error message, it returns an undefined value.
|
|
356
323
|
*/
|
|
357
324
|
getHelpText() {
|
|
@@ -360,15 +327,13 @@ class m {
|
|
|
360
327
|
/**
|
|
361
328
|
* Creates a new instance of FDataValidationBuilder using the current rule object.
|
|
362
329
|
* This method is useful for copying an existing data validation rule configuration.
|
|
363
|
-
*
|
|
364
|
-
* @return A new FDataValidationBuilder instance with the same rule configuration.
|
|
330
|
+
* @returns A new FDataValidationBuilder instance with the same rule configuration.
|
|
365
331
|
*/
|
|
366
332
|
copy() {
|
|
367
333
|
return new D(this.rule);
|
|
368
334
|
}
|
|
369
335
|
/**
|
|
370
336
|
* Gets whether the data validation rule is applied to the worksheet.
|
|
371
|
-
*
|
|
372
337
|
* @returns true if the rule is applied, false otherwise.
|
|
373
338
|
*/
|
|
374
339
|
getApplied() {
|
|
@@ -379,7 +344,6 @@ class m {
|
|
|
379
344
|
}
|
|
380
345
|
/**
|
|
381
346
|
* Gets the ranges to which the data validation rule is applied.
|
|
382
|
-
*
|
|
383
347
|
* @returns An array of IRange objects representing the ranges to which the data validation rule is applied.
|
|
384
348
|
*/
|
|
385
349
|
getRanges() {
|
|
@@ -390,7 +354,6 @@ class m {
|
|
|
390
354
|
}
|
|
391
355
|
/**
|
|
392
356
|
* Gets the title of the error message dialog box.
|
|
393
|
-
*
|
|
394
357
|
* @returns The title of the error message dialog box.
|
|
395
358
|
*/
|
|
396
359
|
getUnitId() {
|
|
@@ -399,7 +362,6 @@ class m {
|
|
|
399
362
|
}
|
|
400
363
|
/**
|
|
401
364
|
* Gets the sheetId of the worksheet.
|
|
402
|
-
*
|
|
403
365
|
* @returns The sheetId of the worksheet.
|
|
404
366
|
*/
|
|
405
367
|
getSheetId() {
|
|
@@ -410,6 +372,7 @@ class m {
|
|
|
410
372
|
* Set Criteria for the data validation rule.
|
|
411
373
|
* @param type The type of data validation criteria.
|
|
412
374
|
* @param values An array containing the operator, formula1, and formula2 values.
|
|
375
|
+
* @param allowBlank
|
|
413
376
|
* @returns true if the criteria is set successfully, false otherwise.
|
|
414
377
|
*/
|
|
415
378
|
setCriteria(e, t, r = !0) {
|
|
@@ -13,43 +13,36 @@ export declare class FDataValidationBuilder {
|
|
|
13
13
|
constructor(rule?: IDataValidationRule);
|
|
14
14
|
/**
|
|
15
15
|
* Builds an FDataValidation instance based on the _rule property of the current class
|
|
16
|
-
*
|
|
17
16
|
* @returns {FDataValidation} A new instance of the FDataValidation class
|
|
18
17
|
*/
|
|
19
18
|
build(): FDataValidation;
|
|
20
19
|
/**
|
|
21
20
|
* Creates a duplicate of the current DataValidationBuilder object
|
|
22
|
-
*
|
|
23
|
-
* @return {FDataValidationBuilder} A new instance of the DataValidationBuilder class
|
|
21
|
+
* @returns {FDataValidationBuilder} A new instance of the DataValidationBuilder class
|
|
24
22
|
*/
|
|
25
23
|
copy(): FDataValidationBuilder;
|
|
26
24
|
/**
|
|
27
25
|
* Determines whether invalid data is allowed
|
|
28
|
-
*
|
|
29
26
|
* @returns {boolean} True if invalid data is allowed, False otherwise
|
|
30
27
|
*/
|
|
31
28
|
getAllowInvalid(): boolean;
|
|
32
29
|
/**
|
|
33
30
|
* Gets the data validation type of the rule
|
|
34
|
-
*
|
|
35
31
|
* @returns {DataValidationType} The data validation type
|
|
36
32
|
*/
|
|
37
33
|
getCriteriaType(): DataValidationType | string;
|
|
38
34
|
/**
|
|
39
35
|
* Gets the values used for criteria evaluation
|
|
40
|
-
*
|
|
41
36
|
* @returns {[string, string, string]} An array containing the operator, formula1, and formula2 values
|
|
42
37
|
*/
|
|
43
38
|
getCriteriaValues(): [string | undefined, string | undefined, string | undefined];
|
|
44
39
|
/**
|
|
45
40
|
* Gets the help text information, which is used to provide users with guidance and support
|
|
46
|
-
*
|
|
47
41
|
* @returns {string | undefined} Returns the help text information. If there is no error message, it returns an undefined value.
|
|
48
42
|
*/
|
|
49
43
|
getHelpText(): string | undefined;
|
|
50
44
|
/**
|
|
51
45
|
* Sets the data validation type to CHECKBOX and sets the checked and unchecked values
|
|
52
|
-
*
|
|
53
46
|
* @param checkedValue The value when the checkbox is checked (Optional)
|
|
54
47
|
* @param uncheckedValue The value when the checkbox is unchecked (Optional)
|
|
55
48
|
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
@@ -57,190 +50,168 @@ export declare class FDataValidationBuilder {
|
|
|
57
50
|
requireCheckbox(checkedValue?: string, uncheckedValue?: string): FDataValidationBuilder;
|
|
58
51
|
/**
|
|
59
52
|
* Set the data validation type to DATE and configure the validation rules to be after a specific date
|
|
60
|
-
*
|
|
61
53
|
* @param date The date to compare against. The formatted date string will be set as formula1
|
|
62
|
-
* @
|
|
54
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
63
55
|
*/
|
|
64
56
|
requireDateAfter(date: Date): FDataValidationBuilder;
|
|
65
57
|
/**
|
|
66
58
|
* Set the data validation type to DATE and configure the validation rules to be before a specific date
|
|
67
|
-
*
|
|
68
59
|
* @param date The date to compare against. The formatted date string will be set as formula1
|
|
69
|
-
* @
|
|
60
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
70
61
|
*/
|
|
71
62
|
requireDateBefore(date: Date): FDataValidationBuilder;
|
|
72
63
|
/**
|
|
73
64
|
* Set the data validation type to DATE and configure the validation rules to be within a specific date range
|
|
74
|
-
*
|
|
75
65
|
* @param start The starting date of the range. The formatted date string will be set as formula1
|
|
76
66
|
* @param end The ending date of the range. The formatted date string will be set as formula2
|
|
77
|
-
* @
|
|
67
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
78
68
|
*/
|
|
79
69
|
requireDateBetween(start: Date, end: Date): FDataValidationBuilder;
|
|
80
70
|
/**
|
|
81
71
|
* Set the data validation type to DATE and configure the validation rules to be equal to a specific date
|
|
82
|
-
*
|
|
83
72
|
* @param date The date to compare against. The formatted date string will be set as formula1
|
|
84
|
-
* @
|
|
73
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
85
74
|
*/
|
|
86
75
|
requireDateEqualTo(date: Date): FDataValidationBuilder;
|
|
87
76
|
/**
|
|
88
77
|
* Set the data validation type to DATE and configure the validation rules to be not within a specific date range
|
|
89
|
-
*
|
|
90
78
|
* @param start The starting date of the date range
|
|
91
79
|
* @param end The ending date of the date range
|
|
92
|
-
* @
|
|
80
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
93
81
|
*/
|
|
94
82
|
requireDateNotBetween(start: Date, end: Date): FDataValidationBuilder;
|
|
95
83
|
/**
|
|
96
84
|
* Set the data validation type to DATE and configure the validation rules to be on or after a specific date
|
|
97
|
-
*
|
|
98
85
|
* @param date The date to compare against. The formatted date string will be set as formula1
|
|
99
|
-
* @
|
|
86
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
100
87
|
*/
|
|
101
88
|
requireDateOnOrAfter(date: Date): FDataValidationBuilder;
|
|
102
89
|
/**
|
|
103
90
|
* Set the data validation type to DATE and configure the validation rules to be on or before a specific date
|
|
104
|
-
*
|
|
105
91
|
* @param date The date to compare against. The formatted date string will be set as formula1
|
|
106
|
-
* @
|
|
92
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
107
93
|
*/
|
|
108
94
|
requireDateOnOrBefore(date: Date): FDataValidationBuilder;
|
|
109
95
|
/**
|
|
110
96
|
* Requires that a custom formula be satisfied.
|
|
111
97
|
* Sets the data validation type to CUSTOM and configures the validation rule based on the provided formula string.
|
|
112
|
-
*
|
|
113
98
|
* @param formula The formula string that needs to be satisfied.
|
|
114
|
-
* @
|
|
99
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
115
100
|
*/
|
|
116
101
|
requireFormulaSatisfied(formula: string): FDataValidationBuilder;
|
|
117
102
|
/**
|
|
118
103
|
* Requires the user to enter a number within a specific range, which can be integer or decimal.
|
|
119
104
|
* Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number range.
|
|
120
|
-
*
|
|
121
105
|
* @param start The starting value of the number range.
|
|
122
106
|
* @param end The ending value of the number range.
|
|
123
107
|
* @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or decimal.
|
|
124
|
-
* @
|
|
108
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
125
109
|
*/
|
|
126
110
|
requireNumberBetween(start: number, end: number, isInteger?: boolean): FDataValidationBuilder;
|
|
127
111
|
/**
|
|
128
112
|
* Requires the user to enter a number that is equal to a specific value, which can be an integer or a decimal.
|
|
129
113
|
* Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number.
|
|
130
|
-
*
|
|
131
114
|
* @param num The number to which the entered number should be equal.
|
|
132
115
|
* @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal.
|
|
133
|
-
* @
|
|
116
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
134
117
|
*/
|
|
135
118
|
requireNumberEqualTo(num: number, isInteger?: boolean): FDataValidationBuilder;
|
|
136
119
|
/**
|
|
137
120
|
* Requires the user to enter a number that is greater than a specific value, which can be an integer or a decimal.
|
|
138
121
|
* Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number.
|
|
139
|
-
*
|
|
140
122
|
* @param num The number to which the entered number should be greater.
|
|
141
123
|
* @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal.
|
|
142
|
-
* @
|
|
124
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
143
125
|
*/
|
|
144
126
|
requireNumberGreaterThan(num: number, isInteger?: boolean): FDataValidationBuilder;
|
|
145
127
|
/**
|
|
146
128
|
* 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.
|
|
147
129
|
* Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number.
|
|
148
|
-
*
|
|
149
130
|
* @param num The number to which the entered number should be greater than or equal.
|
|
150
131
|
* @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal.
|
|
151
|
-
* @
|
|
132
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
152
133
|
*/
|
|
153
134
|
requireNumberGreaterThanOrEqualTo(num: number, isInteger?: boolean): FDataValidationBuilder;
|
|
154
135
|
/**
|
|
155
136
|
* Requires the user to enter a number that is less than a specific value, which can be an integer or a decimal.
|
|
156
137
|
* Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number.
|
|
157
|
-
*
|
|
158
138
|
* @param num The number to which the entered number should be less.
|
|
159
139
|
* @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal.
|
|
160
|
-
* @
|
|
140
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
161
141
|
*/
|
|
162
142
|
requireNumberLessThan(num: number, isInteger?: boolean): FDataValidationBuilder;
|
|
163
143
|
/**
|
|
164
144
|
* Sets the data validation rule to require a number less than or equal to a specified value
|
|
165
145
|
* The specified value can be an integer or a decimal
|
|
166
|
-
*
|
|
167
146
|
* @param num The number to which the entered number should be less than or equal
|
|
168
147
|
* @param isInteger Indicates whether the required number is an integer
|
|
169
|
-
* @
|
|
148
|
+
* @returns The current instance of the DataValidationBuilder class, allowing for method chaining
|
|
170
149
|
*/
|
|
171
150
|
requireNumberLessThanOrEqualTo(num: number, isInteger?: boolean): FDataValidationBuilder;
|
|
172
151
|
/**
|
|
173
152
|
* Sets a data validation rule that requires the user to enter a number outside a specified range
|
|
174
153
|
* The specified range includes all integers and decimals
|
|
175
|
-
*
|
|
176
154
|
* @param start The starting point of the specified range
|
|
177
155
|
* @param end The end point of the specified range
|
|
178
156
|
* @param isInteger Optional parameter, indicating whether the number to be verified is an integer. Default value is false
|
|
179
|
-
* @
|
|
157
|
+
* @returns An instance of the FDataValidationBuilder class, allowing for method chaining
|
|
180
158
|
*/
|
|
181
159
|
requireNumberNotBetween(start: number, end: number, isInteger?: boolean): FDataValidationBuilder;
|
|
182
160
|
/**
|
|
183
161
|
* Creates a data validation rule that requires the user to enter a number that is not equal to a specific value
|
|
184
162
|
* The specific value can be an integer or a decimal
|
|
185
|
-
*
|
|
186
163
|
* @param num The number to which the entered number should not be equal
|
|
187
164
|
* @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal
|
|
188
|
-
* @
|
|
165
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining
|
|
189
166
|
*/
|
|
190
167
|
requireNumberNotEqualTo(num: number, isInteger?: boolean): FDataValidationBuilder;
|
|
191
168
|
/**
|
|
192
169
|
* Sets a data validation rule that requires the user to enter a value from a list of specific values.
|
|
193
170
|
* The list can be displayed in a dropdown, and the user can choose multiple values according to the settings.
|
|
194
|
-
*
|
|
195
171
|
* @param values An array containing the specific values that the user can enter.
|
|
196
172
|
* @param multiple Optional parameter indicating whether the user can select multiple values. Default is false, meaning only one value can be selected.
|
|
197
173
|
* @param showDropdown Optional parameter indicating whether to display the list in a dropdown. Default is true, meaning the list will be displayed as a dropdown.
|
|
198
|
-
* @
|
|
174
|
+
* @returns An instance of the FDataValidationBuilder class, allowing for method chaining.
|
|
199
175
|
*/
|
|
200
176
|
requireValueInList(values: string[], multiple?: boolean, showDropdown?: boolean): FDataValidationBuilder;
|
|
201
177
|
/**
|
|
202
178
|
* Sets a data validation rule that requires the user to enter a value within a specific range.
|
|
203
179
|
* The range is defined by an FRange object, which contains the unit ID, sheet name, and cell range.
|
|
204
|
-
*
|
|
205
180
|
* @param range An FRange object representing the range of values that the user can enter.
|
|
206
181
|
* @param multiple Optional parameter indicating whether the user can select multiple values. Default is false, meaning only one value can be selected.
|
|
207
182
|
* @param showDropdown Optional parameter indicating whether to display the list in a dropdown. Default is true, meaning the list will be displayed as a dropdown.
|
|
208
|
-
* @
|
|
183
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
209
184
|
*/
|
|
210
185
|
requireValueInRange(range: FRange, multiple?: boolean, showDropdown?: boolean): FDataValidationBuilder;
|
|
211
186
|
/**
|
|
212
187
|
* Sets whether to allow invalid data and configures the error style for data validation.
|
|
213
188
|
* If invalid data is not allowed, the error style will be set to STOP, indicating that data entry must stop upon encountering an error.
|
|
214
189
|
* 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.
|
|
215
|
-
*
|
|
216
190
|
* @param allowInvalidData A boolean value indicating whether to allow invalid data.
|
|
217
|
-
* @
|
|
191
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
218
192
|
*/
|
|
219
193
|
setAllowInvalid(allowInvalidData: boolean): FDataValidationBuilder;
|
|
220
194
|
/**
|
|
221
195
|
* Sets the help text and enables the display of error messages for data validation.
|
|
222
196
|
* This method allows you to set a custom help text that will be displayed when the user enters invalid data.
|
|
223
|
-
*
|
|
224
197
|
* @param helpText The text to display as help information.
|
|
225
|
-
* @
|
|
198
|
+
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
226
199
|
*/
|
|
227
200
|
setHelpText(helpText: string): FDataValidationBuilder;
|
|
228
201
|
/**
|
|
229
202
|
* Sets the criteria values for data validation.
|
|
230
203
|
* This method is used to configure the validation rules based on specific criteria values.
|
|
231
|
-
*
|
|
232
204
|
* @param type The type of data validation.
|
|
233
205
|
* @param values An array containing the criteria values.
|
|
234
206
|
* The array should have three elements: [operator, formula1, formula2].
|
|
235
207
|
* operator is a DataValidationOperator enum value, formula1 is the first formula, and formula2 is the second formula.
|
|
236
|
-
* @
|
|
208
|
+
* @returns The current instance of the FDataValidationBuilder class, allowing for method chaining.
|
|
237
209
|
*/
|
|
238
210
|
withCriteriaValues(type: DataValidationType | string, values: [DataValidationOperator, string, string]): this;
|
|
239
211
|
setAllowBlank(allowBlank: boolean): FDataValidationBuilder;
|
|
240
212
|
/**
|
|
241
213
|
* Sets the options for the data validation rule.
|
|
242
214
|
* For details of options, please refer to https://univer.ai/typedoc/@univerjs/core/interfaces/IDataValidationRuleOptions
|
|
243
|
-
*
|
|
244
215
|
* @param options The options to set for the data validation rule.
|
|
245
216
|
* @returns The current instance of the FDataValidationBuilder class to allow for method chaining.
|
|
246
217
|
*/
|
|
@@ -8,56 +8,47 @@ export declare class FDataValidation {
|
|
|
8
8
|
constructor(rule: IDataValidationRule, worksheet?: Worksheet, _injector?: Injector);
|
|
9
9
|
/**
|
|
10
10
|
* Gets whether invalid data is allowed based on the error style value.
|
|
11
|
-
*
|
|
12
|
-
* @return true if invalid data is allowed, false otherwise.
|
|
11
|
+
* @returns true if invalid data is allowed, false otherwise.
|
|
13
12
|
*/
|
|
14
13
|
getAllowInvalid(): boolean;
|
|
15
14
|
/**
|
|
16
15
|
* Gets the data validation type of the rule
|
|
17
|
-
*
|
|
18
16
|
* @returns The data validation type
|
|
19
17
|
*/
|
|
20
18
|
getCriteriaType(): DataValidationType | string;
|
|
21
19
|
/**
|
|
22
20
|
* Gets the values used for criteria evaluation
|
|
23
|
-
*
|
|
24
21
|
* @returns An array containing the operator, formula1, and formula2 values
|
|
25
22
|
*/
|
|
26
23
|
getCriteriaValues(): [string | undefined, string | undefined, string | undefined];
|
|
27
24
|
/**
|
|
28
25
|
* Gets the help text information, which is used to provide users with guidance and support
|
|
29
|
-
*
|
|
30
26
|
* @returns Returns the help text information. If there is no error message, it returns an undefined value.
|
|
31
27
|
*/
|
|
32
28
|
getHelpText(): string | undefined;
|
|
33
29
|
/**
|
|
34
30
|
* Creates a new instance of FDataValidationBuilder using the current rule object.
|
|
35
31
|
* This method is useful for copying an existing data validation rule configuration.
|
|
36
|
-
*
|
|
37
|
-
* @return A new FDataValidationBuilder instance with the same rule configuration.
|
|
32
|
+
* @returns A new FDataValidationBuilder instance with the same rule configuration.
|
|
38
33
|
*/
|
|
39
34
|
copy(): FDataValidationBuilder;
|
|
40
35
|
/**
|
|
41
36
|
* Gets whether the data validation rule is applied to the worksheet.
|
|
42
|
-
*
|
|
43
37
|
* @returns true if the rule is applied, false otherwise.
|
|
44
38
|
*/
|
|
45
39
|
getApplied(): boolean;
|
|
46
40
|
/**
|
|
47
41
|
* Gets the ranges to which the data validation rule is applied.
|
|
48
|
-
*
|
|
49
42
|
* @returns An array of IRange objects representing the ranges to which the data validation rule is applied.
|
|
50
43
|
*/
|
|
51
44
|
getRanges(): FRange[];
|
|
52
45
|
/**
|
|
53
46
|
* Gets the title of the error message dialog box.
|
|
54
|
-
*
|
|
55
47
|
* @returns The title of the error message dialog box.
|
|
56
48
|
*/
|
|
57
49
|
getUnitId(): string | undefined;
|
|
58
50
|
/**
|
|
59
51
|
* Gets the sheetId of the worksheet.
|
|
60
|
-
*
|
|
61
52
|
* @returns The sheetId of the worksheet.
|
|
62
53
|
*/
|
|
63
54
|
getSheetId(): string | undefined;
|
|
@@ -65,6 +56,7 @@ export declare class FDataValidation {
|
|
|
65
56
|
* Set Criteria for the data validation rule.
|
|
66
57
|
* @param type The type of data validation criteria.
|
|
67
58
|
* @param values An array containing the operator, formula1, and formula2 values.
|
|
59
|
+
* @param allowBlank
|
|
68
60
|
* @returns true if the criteria is set successfully, false otherwise.
|
|
69
61
|
*/
|
|
70
62
|
setCriteria(type: DataValidationType, values: [DataValidationOperator, string, string], allowBlank?: boolean): FDataValidation;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-data-validation",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4-nightly.202501131606",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Data validation for Univer Sheets",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -54,11 +54,11 @@
|
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@univerjs/protocol": "0.1.40",
|
|
57
|
-
"@univerjs/core": "0.5.
|
|
58
|
-
"@univerjs/data-validation": "0.5.
|
|
59
|
-
"@univerjs/
|
|
60
|
-
"@univerjs/sheets
|
|
61
|
-
"@univerjs/
|
|
57
|
+
"@univerjs/core": "0.5.4-nightly.202501131606",
|
|
58
|
+
"@univerjs/data-validation": "0.5.4-nightly.202501131606",
|
|
59
|
+
"@univerjs/engine-formula": "0.5.4-nightly.202501131606",
|
|
60
|
+
"@univerjs/sheets": "0.5.4-nightly.202501131606",
|
|
61
|
+
"@univerjs/sheets-formula": "0.5.4-nightly.202501131606"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"less": "^4.2.1",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"typescript": "^5.7.2",
|
|
67
67
|
"vite": "^6.0.7",
|
|
68
68
|
"vitest": "^2.1.8",
|
|
69
|
-
"@univerjs-infra/shared": "0.5.
|
|
69
|
+
"@univerjs-infra/shared": "0.5.4"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"dev": "vite",
|