@univerjs/sheets-data-validation 0.6.1 → 0.6.2-nightly.202503031606

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
@@ -24,6 +24,8 @@ class E {
24
24
  * ```typescript
25
25
  * const fWorkbook = univerAPI.getActiveWorkbook();
26
26
  * const fWorksheet = fWorkbook.getActiveSheet();
27
+ *
28
+ * // Create a new data validation rule that requires a number between 1 and 10 for the range A1:B10
27
29
  * const fRange = fWorksheet.getRange('A1:B10');
28
30
  * const rule = univerAPI.newDataValidation()
29
31
  * .requireNumberBetween(1, 10)
@@ -44,9 +46,24 @@ class E {
44
46
  * @returns {FDataValidationBuilder} A new instance of the DataValidationBuilder class
45
47
  * @example
46
48
  * ```typescript
47
- * const builder = univerAPI.newDataValidation().requireNumberBetween(1, 10);
49
+ * const fWorkbook = univerAPI.getActiveWorkbook();
50
+ * const fWorksheet = fWorkbook.getActiveSheet();
51
+ *
52
+ * // Create a new data validation rule that requires a number between 1 and 10 for the range A1:B10
53
+ * const fRange = fWorksheet.getRange('A1:B10');
54
+ * const builder = univerAPI.newDataValidation()
55
+ * .requireNumberBetween(1, 10)
56
+ * .setOptions({
57
+ * allowBlank: true,
58
+ * showErrorMessage: true,
59
+ * error: 'Please enter a number between 1 and 10'
60
+ * });
61
+ * fRange.setDataValidation(builder.build());
62
+ *
63
+ * // Copy the builder applied to the new range F1:G10
64
+ * const newRange = fWorksheet.getRange('F1:G10');
48
65
  * const copyBuilder = builder.copy();
49
- * console.log(copyBuilder);
66
+ * newRange.setDataValidation(copyBuilder.build());
50
67
  * ```
51
68
  */
52
69
  copy() {
@@ -73,13 +90,13 @@ class E {
73
90
  * @example
74
91
  * ```typescript
75
92
  * const builder = univerAPI.newDataValidation();
76
- * console.log(builder.getCriteriaType());
93
+ * console.log(builder.getCriteriaType()); // custom
77
94
  *
78
95
  * builder.requireNumberBetween(1, 10);
79
- * console.log(builder.getCriteriaType());
96
+ * console.log(builder.getCriteriaType()); // decimal
80
97
  *
81
98
  * builder.requireValueInList(['Yes', 'No']);
82
- * console.log(builder.getCriteriaType());
99
+ * console.log(builder.getCriteriaType()); // list
83
100
  * ```
84
101
  */
85
102
  getCriteriaType() {
@@ -92,10 +109,10 @@ class E {
92
109
  * ```typescript
93
110
  * const builder = univerAPI.newDataValidation().requireNumberBetween(1, 10);
94
111
  * const [operator, formula1, formula2] = builder.getCriteriaValues();
95
- * console.log(operator, formula1, formula2);
112
+ * console.log(operator, formula1, formula2); // between 1 10
96
113
  *
97
114
  * builder.requireValueInList(['Yes', 'No']);
98
- * console.log(builder.getCriteriaValues());
115
+ * console.log(builder.getCriteriaValues()); // undefined Yes,No undefined
99
116
  * ```
100
117
  */
101
118
  getCriteriaValues() {
@@ -117,10 +134,10 @@ class E {
117
134
  return this._rule.error;
118
135
  }
119
136
  /**
120
- * Sets the data validation type to CHECKBOX and sets the checked and unchecked values
121
- * @param {string} [checkedValue] - The value when the checkbox is checked
122
- * @param {string} [uncheckedValue] - The value when the checkbox is unchecked
123
- * @returns {FDataValidationBuilder} The current instance for method chaining
137
+ * Sets the data validation rule to require that the input is a boolean value; this value is rendered as a checkbox.
138
+ * @param {string} [checkedValue] - The value assigned to a checked box.
139
+ * @param {string} [uncheckedValue] - The value assigned to an unchecked box.
140
+ * @returns {FDataValidationBuilder} The current instance for method chaining.
124
141
  * @example
125
142
  * ```typescript
126
143
  * const fWorkbook = univerAPI.getActiveWorkbook();
@@ -145,23 +162,28 @@ class E {
145
162
  return this._rule.type = o.CHECKBOX, this._rule.formula1 = e, this._rule.formula2 = t, this;
146
163
  }
147
164
  /**
148
- * Set the data validation type to DATE and configure the validation rules to be after a specific date
149
- * @param {Date} date - The date to compare against
150
- * @returns {FDataValidationBuilder} The current instance for method chaining
165
+ * Set the data validation type to DATE and configure the validation rules to be after a specific date.
166
+ * @param {Date} date - The latest unacceptable date.
167
+ * @returns {FDataValidationBuilder} The current instance for method chaining.
151
168
  * @example
152
169
  * ```typescript
153
170
  * const fWorkbook = univerAPI.getActiveWorkbook();
154
171
  * const fWorksheet = fWorkbook.getActiveSheet();
172
+ *
173
+ * // Set some date values in the range A1:B2
155
174
  * const fRange = fWorksheet.getRange('A1:B2');
156
175
  * fRange.setValues([
157
176
  * ['2024-01-01', '2024-12-31'],
158
177
  * ['2025-01-01', '2025-12-31']
159
178
  * ]);
179
+ *
180
+ * // Create a data validation rule that requires a date after 2025-01-01
160
181
  * const rule = univerAPI.newDataValidation()
161
182
  * .requireDateAfter(new Date('2025-01-01'))
162
183
  * .build();
163
184
  * fRange.setDataValidation(rule);
164
185
  *
186
+ * // Get the validation status of the range
165
187
  * const status = await fRange.getValidatorStatus();
166
188
  * console.log(status); // [['invalid', 'invalid', 'invalid', 'valid']]
167
189
  * ```
@@ -170,23 +192,28 @@ class E {
170
192
  return this._rule.type = o.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.operator = h.GREATER_THAN, this;
171
193
  }
172
194
  /**
173
- * Set the data validation type to DATE and configure the validation rules to be before a specific date
174
- * @param {Date} date - The date to compare against
175
- * @returns {FDataValidationBuilder} The current instance for method chaining
195
+ * Set the data validation type to DATE and configure the validation rules to be before a specific date.
196
+ * @param {Date} date - The earliest unacceptable date.
197
+ * @returns {FDataValidationBuilder} The current instance for method chaining.
176
198
  * @example
177
199
  * ```typescript
178
200
  * const fWorkbook = univerAPI.getActiveWorkbook();
179
201
  * const fWorksheet = fWorkbook.getActiveSheet();
202
+ *
203
+ * // Set some date values in the range A1:B2
180
204
  * const fRange = fWorksheet.getRange('A1:B2');
181
205
  * fRange.setValues([
182
206
  * ['2024-01-01', '2024-12-31'],
183
207
  * ['2025-01-01', '2025-12-31']
184
208
  * ]);
209
+ *
210
+ * // Create a data validation rule that requires a date before 2025-01-01
185
211
  * const rule = univerAPI.newDataValidation()
186
212
  * .requireDateBefore(new Date('2025-01-01'))
187
213
  * .build();
188
214
  * fRange.setDataValidation(rule);
189
215
  *
216
+ * // Get the validation status of the range
190
217
  * const status = await fRange.getValidatorStatus();
191
218
  * console.log(status); // [['valid', 'valid', 'invalid', 'invalid']]
192
219
  * ```
@@ -195,24 +222,29 @@ class E {
195
222
  return this._rule.type = o.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = h.LESS_THAN, this;
196
223
  }
197
224
  /**
198
- * Set the data validation type to DATE and configure the validation rules to be within a specific date range
199
- * @param {Date} start - The starting date of the range
200
- * @param {Date} end - The ending date of the range
201
- * @returns {FDataValidationBuilder} The current instance for method chaining
225
+ * Set the data validation type to DATE and configure the validation rules to be within a specific date range.
226
+ * @param {Date} start - The earliest acceptable date.
227
+ * @param {Date} end - The latest acceptable date.
228
+ * @returns {FDataValidationBuilder} The current instance for method chaining.
202
229
  * @example
203
230
  * ```typescript
204
231
  * const fWorkbook = univerAPI.getActiveWorkbook();
205
232
  * const fWorksheet = fWorkbook.getActiveSheet();
233
+ *
234
+ * // Set some date values in the range A1:B2
206
235
  * const fRange = fWorksheet.getRange('A1:B2');
207
236
  * fRange.setValues([
208
237
  * ['2024-01-01', '2024-12-31'],
209
238
  * ['2025-01-01', '2025-12-31']
210
239
  * ]);
240
+ *
241
+ * // Create a data validation rule that requires a date between 2024-06-01 and 2025-06-01
211
242
  * const rule = univerAPI.newDataValidation()
212
243
  * .requireDateBetween(new Date('2024-06-01'), new Date('2025-06-01'))
213
244
  * .build();
214
245
  * fRange.setDataValidation(rule);
215
246
  *
247
+ * // Get the validation status of the range
216
248
  * const status = await fRange.getValidatorStatus();
217
249
  * console.log(status); // [['invalid', 'valid', 'valid', 'invalid']]
218
250
  * ```
@@ -221,26 +253,32 @@ class E {
221
253
  return this._rule.type = o.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = t.toLocaleDateString(), this._rule.operator = h.BETWEEN, this;
222
254
  }
223
255
  /**
224
- * Set the data validation type to DATE and configure the validation rules to be equal to a specific date
225
- * @param {Date} date - The date to compare against
226
- * @returns {FDataValidationBuilder} The current instance for method chaining
256
+ * Set the data validation type to DATE and configure the validation rules to be equal to a specific date.
257
+ * @param {Date} date - The sole acceptable date.
258
+ * @returns {FDataValidationBuilder} The current instance for method chaining.
227
259
  * @example
228
260
  * ```typescript
229
261
  * const fWorkbook = univerAPI.getActiveWorkbook();
230
262
  * const fWorksheet = fWorkbook.getActiveSheet();
263
+ *
264
+ * // Set some date values in the range A1:B2
231
265
  * const fRange = fWorksheet.getRange('A1:B2');
232
266
  * fRange.setValues([
233
267
  * ['2024-01-01', '2024-12-31'],
234
268
  * ['2025-01-01', '2025-12-31']
235
269
  * ]);
270
+ *
271
+ * // Create a data validation rule that requires a date equal to 2025-01-01
236
272
  * const rule = univerAPI.newDataValidation()
237
273
  * .requireDateEqualTo(new Date('2025-01-01'))
238
274
  * .build();
239
275
  * fRange.setDataValidation(rule);
240
276
  *
277
+ * // Get the validation status of the cell A2
241
278
  * const status = await fWorksheet.getRange('A2').getValidatorStatus();
242
279
  * console.log(status?.[0]?.[0]); // 'valid'
243
280
  *
281
+ * // Get the validation status of the cell B2
244
282
  * const status2 = await fWorksheet.getRange('B2').getValidatorStatus();
245
283
  * console.log(status2?.[0]?.[0]); // 'invalid'
246
284
  * ```
@@ -249,24 +287,29 @@ class E {
249
287
  return this._rule.type = o.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = h.EQUAL, this;
250
288
  }
251
289
  /**
252
- * Set the data validation type to DATE and configure the validation rules to be not within a specific date range
253
- * @param {Date} start - The starting date of the date range
254
- * @param {Date} end - The ending date of the date range
255
- * @returns {FDataValidationBuilder} The current instance for method chaining
290
+ * Set the data validation type to DATE and configure the validation rules to be not within a specific date range.
291
+ * @param {Date} start - The earliest unacceptable date.
292
+ * @param {Date} end - The latest unacceptable date.
293
+ * @returns {FDataValidationBuilder} The current instance for method chaining.
256
294
  * @example
257
295
  * ```typescript
258
296
  * const fWorkbook = univerAPI.getActiveWorkbook();
259
297
  * const fWorksheet = fWorkbook.getActiveSheet();
298
+ *
299
+ * // Set some date values in the range A1:B2
260
300
  * const fRange = fWorksheet.getRange('A1:B2');
261
301
  * fRange.setValues([
262
302
  * ['2024-01-01', '2024-12-31'],
263
303
  * ['2025-01-01', '2025-12-31']
264
304
  * ]);
305
+ *
306
+ * // Create a data validation rule that requires a date not between 2024-06-01 and 2025-06-01
265
307
  * const rule = univerAPI.newDataValidation()
266
308
  * .requireDateNotBetween(new Date('2024-06-01'), new Date('2025-06-01'))
267
309
  * .build();
268
310
  * fRange.setDataValidation(rule);
269
311
  *
312
+ * // Get the validation status of the range
270
313
  * const status = await fRange.getValidatorStatus();
271
314
  * console.log(status); // [['valid', 'invalid', 'invalid', 'valid']]
272
315
  * ```
@@ -275,23 +318,28 @@ class E {
275
318
  return this._rule.type = o.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = t.toLocaleDateString(), this._rule.operator = h.NOT_BETWEEN, this;
276
319
  }
277
320
  /**
278
- * Set the data validation type to DATE and configure the validation rules to be on or after a specific date
279
- * @param {Date} date - The date to compare against
280
- * @returns {FDataValidationBuilder} The current instance for method chaining
321
+ * Set the data validation type to DATE and configure the validation rules to be on or after a specific date.
322
+ * @param {Date} date - The earliest acceptable date.
323
+ * @returns {FDataValidationBuilder} The current instance for method chaining.
281
324
  * @example
282
325
  * ```typescript
283
326
  * const fWorkbook = univerAPI.getActiveWorkbook();
284
327
  * const fWorksheet = fWorkbook.getActiveSheet();
328
+ *
329
+ * // Set some date values in the range A1:B2
285
330
  * const fRange = fWorksheet.getRange('A1:B2');
286
331
  * fRange.setValues([
287
332
  * ['2024-01-01', '2024-12-31'],
288
333
  * ['2025-01-01', '2025-12-31']
289
334
  * ]);
335
+ *
336
+ * // Create a data validation rule that requires a date on or after 2025-01-01
290
337
  * const rule = univerAPI.newDataValidation()
291
338
  * .requireDateOnOrAfter(new Date('2025-01-01'))
292
339
  * .build();
293
340
  * fRange.setDataValidation(rule);
294
341
  *
342
+ * // Get the validation status of the range
295
343
  * const status = await fRange.getValidatorStatus();
296
344
  * console.log(status); // [['invalid', 'invalid', 'valid', 'valid']]
297
345
  * ```
@@ -300,23 +348,28 @@ class E {
300
348
  return this._rule.type = o.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = h.GREATER_THAN_OR_EQUAL, this;
301
349
  }
302
350
  /**
303
- * Set the data validation type to DATE and configure the validation rules to be on or before a specific date
304
- * @param {Date} date - The date to compare against
305
- * @returns {FDataValidationBuilder} The current instance for method chaining
351
+ * Set the data validation type to DATE and configure the validation rules to be on or before a specific date.
352
+ * @param {Date} date - The latest acceptable date.
353
+ * @returns {FDataValidationBuilder} The current instance for method chaining.
306
354
  * @example
307
355
  * ```typescript
308
356
  * const fWorkbook = univerAPI.getActiveWorkbook();
309
357
  * const fWorksheet = fWorkbook.getActiveSheet();
358
+ *
359
+ * // Set some date values in the range A1:B2
310
360
  * const fRange = fWorksheet.getRange('A1:B2');
311
361
  * fRange.setValues([
312
362
  * ['2024-01-01', '2024-12-31'],
313
363
  * ['2025-01-01', '2025-12-31']
314
364
  * ]);
365
+ *
366
+ * // Create a data validation rule that requires a date on or before 2025-01-01
315
367
  * const rule = univerAPI.newDataValidation()
316
368
  * .requireDateOnOrBefore(new Date('2025-01-01'))
317
369
  * .build();
318
370
  * fRange.setDataValidation(rule);
319
371
  *
372
+ * // Get the validation status of the range
320
373
  * const status = await fRange.getValidatorStatus();
321
374
  * console.log(status); // [['valid', 'valid', 'valid', 'invalid']]
322
375
  * ```
@@ -325,13 +378,15 @@ class E {
325
378
  return this._rule.type = o.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = h.LESS_THAN_OR_EQUAL, this;
326
379
  }
327
380
  /**
328
- * Requires that a custom formula be satisfied
329
- * @param {string} formula - The formula string that needs to be satisfied, formula result should be TRUE or FALSE, and references range will relative offset
330
- * @returns {FDataValidationBuilder} The current instance for method chaining
381
+ * Sets the data validation rule to require that the given formula evaluates to `true`.
382
+ * @param {string} formula - The formula string that needs to be satisfied, formula result should be TRUE or FALSE, and references range will relative offset.
383
+ * @returns {FDataValidationBuilder} The current instance for method chaining.
331
384
  * @example
332
385
  * ```typescript
333
386
  * const fWorkbook = univerAPI.getActiveWorkbook();
334
387
  * const fWorksheet = fWorkbook.getActiveSheet();
388
+ *
389
+ * // Set some values in the range A1:B2 and C1:D2
335
390
  * const cell = fWorksheet.getRange('A1:B2');
336
391
  * cell.setValues([
337
392
  * [4, 3],
@@ -342,6 +397,8 @@ class E {
342
397
  * [1, 2],
343
398
  * [3, 4]
344
399
  * ]);
400
+ *
401
+ * // Create a data validation rule that requires the formula '=A1>2' to be satisfied
345
402
  * const rule = univerAPI.newDataValidation()
346
403
  * .requireFormulaSatisfied('=A1>2')
347
404
  * .setOptions({
@@ -351,6 +408,7 @@ class E {
351
408
  * .build();
352
409
  * fRange.setDataValidation(rule);
353
410
  *
411
+ * // Get the validation status of the range
354
412
  * const status = await fRange.getValidatorStatus();
355
413
  * console.log(status); // [['valid', 'valid', 'invalid', 'invalid']]
356
414
  * ```
@@ -359,15 +417,17 @@ class E {
359
417
  return this._rule.type = o.CUSTOM, this._rule.formula1 = e, this._rule.formula2 = void 0, this;
360
418
  }
361
419
  /**
362
- * Requires the user to enter a number within a specific range, which can be integer or decimal
363
- * @param {number} start - The starting value of the number range
364
- * @param {number} end - The ending value of the number range
365
- * @param {boolean} [isInteger] - Indicates whether the required number is an integer
366
- * @returns {FDataValidationBuilder} The current instance for method chaining
420
+ * Sets the data validation rule to require a number that falls between, or is either of, two specified numbers.
421
+ * @param {number} start - The lowest acceptable value.
422
+ * @param {number} end - The highest acceptable value.
423
+ * @param {boolean} [isInteger] - Indicates whether the required number is an integer.
424
+ * @returns {FDataValidationBuilder} The current instance for method chaining.
367
425
  * @example
368
426
  * ```typescript
369
427
  * const fWorkbook = univerAPI.getActiveWorkbook();
370
428
  * const fWorksheet = fWorkbook.getActiveSheet();
429
+ *
430
+ * // Create a new data validation rule that requires a number between 1 and 10 for the range A1:B10
371
431
  * const fRange = fWorksheet.getRange('A1:B10');
372
432
  * const rule = univerAPI.newDataValidation()
373
433
  * .requireNumberBetween(1, 10)
@@ -384,14 +444,16 @@ class E {
384
444
  return this._rule.formula1 = `${e}`, this._rule.formula2 = `${t}`, this._rule.operator = h.BETWEEN, this._rule.type = i ? o.WHOLE : o.DECIMAL, this;
385
445
  }
386
446
  /**
387
- * Requires the user to enter a number that is equal to a specific value, which can be an integer or a decimal
388
- * @param {number} num - The number to which the entered number should be equal
389
- * @param {boolean} [isInteger] - Indicates whether the required number is an integer
390
- * @returns {FDataValidationBuilder} The current instance for method chaining
447
+ * Sets the data validation rule to require a number equal to the given value.
448
+ * @param {number} num - The sole acceptable value.
449
+ * @param {boolean} [isInteger] - Indicates whether the required number is an integer.
450
+ * @returns {FDataValidationBuilder} The current instance for method chaining.
391
451
  * @example
392
452
  * ```typescript
393
453
  * const fWorkbook = univerAPI.getActiveWorkbook();
394
454
  * const fWorksheet = fWorkbook.getActiveSheet();
455
+ *
456
+ * // Create a new data validation rule that requires a number equal to 10 for the range A1:B10
395
457
  * const fRange = fWorksheet.getRange('A1:B10');
396
458
  * const rule = univerAPI.newDataValidation()
397
459
  * .requireNumberEqualTo(10)
@@ -408,14 +470,16 @@ class E {
408
470
  return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = h.EQUAL, this._rule.type = t ? o.WHOLE : o.DECIMAL, this;
409
471
  }
410
472
  /**
411
- * Requires the user to enter a number that is greater than a specific value, which can be an integer or a decimal
412
- * @param {number} num - The number to which the entered number should be greater
413
- * @param {boolean} [isInteger] - Indicates whether the required number is an integer
414
- * @returns {FDataValidationBuilder} The current instance for method chaining
473
+ * Sets the data validation rule to require a number greater than the given value.
474
+ * @param {number} num - The highest unacceptable value.
475
+ * @param {boolean} [isInteger] - Indicates whether the required number is an integer.
476
+ * @returns {FDataValidationBuilder} The current instance for method chaining.
415
477
  * @example
416
478
  * ```typescript
417
479
  * const fWorkbook = univerAPI.getActiveWorkbook();
418
480
  * const fWorksheet = fWorkbook.getActiveSheet();
481
+ *
482
+ * // Create a new data validation rule that requires a number greater than 10 for the range A1:B10
419
483
  * const fRange = fWorksheet.getRange('A1:B10');
420
484
  * const rule = univerAPI.newDataValidation()
421
485
  * .requireNumberGreaterThan(10)
@@ -432,14 +496,16 @@ class E {
432
496
  return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = h.GREATER_THAN, this._rule.type = t ? o.WHOLE : o.DECIMAL, this;
433
497
  }
434
498
  /**
435
- * 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
436
- * @param {number} num - The number to which the entered number should be greater than or equal
437
- * @param {boolean} [isInteger] - Indicates whether the required number is an integer
438
- * @returns {FDataValidationBuilder} The current instance for method chaining
499
+ * Sets the data validation rule to require a number greater than or equal to the given value.
500
+ * @param {number} num - The lowest acceptable value.
501
+ * @param {boolean} [isInteger] - Indicates whether the required number is an integer.
502
+ * @returns {FDataValidationBuilder} The current instance for method chaining.
439
503
  * @example
440
504
  * ```typescript
441
505
  * const fWorkbook = univerAPI.getActiveWorkbook();
442
506
  * const fWorksheet = fWorkbook.getActiveSheet();
507
+ *
508
+ * // Create a new data validation rule that requires a number greater than 10 or equal to 10 for the range A1:B10
443
509
  * const fRange = fWorksheet.getRange('A1:B10');
444
510
  * const rule = univerAPI.newDataValidation()
445
511
  * .requireNumberGreaterThanOrEqualTo(10)
@@ -456,14 +522,16 @@ class E {
456
522
  return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = h.GREATER_THAN_OR_EQUAL, this._rule.type = t ? o.WHOLE : o.DECIMAL, this;
457
523
  }
458
524
  /**
459
- * Requires the user to enter a number that is less than a specific value, which can be an integer or a decimal
460
- * @param {number} num - The number to which the entered number should be less
461
- * @param {boolean} [isInteger] - Indicates whether the required number is an integer
462
- * @returns {FDataValidationBuilder} The current instance for method chaining
525
+ * Sets the data validation rule to require a number less than the given value.
526
+ * @param {number} num - The lowest unacceptable value.
527
+ * @param {boolean} [isInteger] - Indicates whether the required number is an integer.
528
+ * @returns {FDataValidationBuilder} The current instance for method chaining.
463
529
  * @example
464
530
  * ```typescript
465
531
  * const fWorkbook = univerAPI.getActiveWorkbook();
466
532
  * const fWorksheet = fWorkbook.getActiveSheet();
533
+ *
534
+ * // Create a new data validation rule that requires a number less than 10 for the range A1:B10
467
535
  * const fRange = fWorksheet.getRange('A1:B10');
468
536
  * const rule = univerAPI.newDataValidation()
469
537
  * .requireNumberLessThan(10)
@@ -480,15 +548,16 @@ class E {
480
548
  return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = h.LESS_THAN, this._rule.type = t ? o.WHOLE : o.DECIMAL, this;
481
549
  }
482
550
  /**
483
- * Sets the data validation rule to require a number less than or equal to a specified value
484
- * The specified value can be an integer or a decimal
485
- * @param {number} num - The number to which the entered number should be less than or equal
486
- * @param {boolean} [isInteger] - Indicates whether the required number is an integer
487
- * @returns {FDataValidationBuilder} The current instance for method chaining
551
+ * Sets the data validation rule to require a number less than or equal to the given value.
552
+ * @param {number} num - The highest acceptable value.
553
+ * @param {boolean} [isInteger] - Indicates whether the required number is an integer.
554
+ * @returns {FDataValidationBuilder} The current instance for method chaining.
488
555
  * @example
489
556
  * ```typescript
490
557
  * const fWorkbook = univerAPI.getActiveWorkbook();
491
558
  * const fWorksheet = fWorkbook.getActiveSheet();
559
+ *
560
+ * // Create a new data validation rule that requires a number less than 10 or equal to 10 for the range A1:B10
492
561
  * const fRange = fWorksheet.getRange('A1:B10');
493
562
  * const rule = univerAPI.newDataValidation()
494
563
  * .requireNumberLessThanOrEqualTo(10)
@@ -505,16 +574,17 @@ class E {
505
574
  return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = h.LESS_THAN_OR_EQUAL, this._rule.type = t ? o.WHOLE : o.DECIMAL, this;
506
575
  }
507
576
  /**
508
- * Sets a data validation rule that requires the user to enter a number outside a specified range
509
- * The specified range includes all integers and decimals
510
- * @param {number} start - The starting point of the specified range
511
- * @param {number} end - The end point of the specified range
512
- * @param {boolean} [isInteger] - Optional parameter, indicating whether the number to be verified is an integer
513
- * @returns {FDataValidationBuilder} The current instance for method chaining
577
+ * Sets the data validation rule to require a number that does not fall between, and is neither of, two specified numbers.
578
+ * @param {number} start - The lowest unacceptable value.
579
+ * @param {number} end - The highest unacceptable value.
580
+ * @param {boolean} [isInteger] - Optional parameter, indicating whether the number to be verified is an integer.
581
+ * @returns {FDataValidationBuilder} The current instance for method chaining.
514
582
  * @example
515
583
  * ```typescript
516
584
  * const fWorkbook = univerAPI.getActiveWorkbook();
517
585
  * const fWorksheet = fWorkbook.getActiveSheet();
586
+ *
587
+ * // Create a new data validation rule that requires a number not between 1 and 10 for the range A1:B10
518
588
  * const fRange = fWorksheet.getRange('A1:B10');
519
589
  * const rule = univerAPI.newDataValidation()
520
590
  * .requireNumberNotBetween(1, 10)
@@ -531,15 +601,16 @@ class E {
531
601
  return this._rule.formula1 = `${e}`, this._rule.formula2 = `${t}`, this._rule.operator = h.NOT_BETWEEN, this._rule.type = i ? o.WHOLE : o.DECIMAL, this;
532
602
  }
533
603
  /**
534
- * Creates a data validation rule that requires the user to enter a number that is not equal to a specific value
535
- * The specific value can be an integer or a decimal
536
- * @param {number} num - The number to which the entered number should not be equal
537
- * @param {boolean} [isInteger] - Indicates whether the required number is an integer
538
- * @returns {FDataValidationBuilder} The current instance for method chaining
604
+ * Sets the data validation rule to require a number not equal to the given value.
605
+ * @param {number} num - The sole unacceptable value.
606
+ * @param {boolean} [isInteger] - Indicates whether the required number is an integer.
607
+ * @returns {FDataValidationBuilder} The current instance for method chaining.
539
608
  * @example
540
609
  * ```typescript
541
610
  * const fWorkbook = univerAPI.getActiveWorkbook();
542
611
  * const fWorksheet = fWorkbook.getActiveSheet();
612
+ *
613
+ * // Create a new data validation rule that requires a number not equal to 10 for the range A1:B10
543
614
  * const fRange = fWorksheet.getRange('A1:B10');
544
615
  * const rule = univerAPI.newDataValidation()
545
616
  * .requireNumberNotEqualTo(10)
@@ -556,16 +627,18 @@ class E {
556
627
  return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = h.NOT_EQUAL, this._rule.type = t ? o.WHOLE : o.DECIMAL, this;
557
628
  }
558
629
  /**
559
- * Sets a data validation rule that requires the user to enter a value from a list of specific values
560
- * The list can be displayed in a dropdown, and the user can choose multiple values according to the settings
561
- * @param {string[]} values - An array containing the specific values that the user can enter
562
- * @param {boolean} [multiple] - Optional parameter indicating whether the user can select multiple values
563
- * @param {boolean} [showDropdown] - Optional parameter indicating whether to display the list in a dropdown
564
- * @returns {FDataValidationBuilder} The current instance for method chaining
630
+ * Sets a data validation rule that requires the user to enter a value from a list of specific values.
631
+ * The list can be displayed in a dropdown, and the user can choose multiple values according to the settings.
632
+ * @param {string[]} values - An array of acceptable values.
633
+ * @param {boolean} [multiple] - Optional parameter indicating whether the user can select multiple values.
634
+ * @param {boolean} [showDropdown] - Optional parameter indicating whether to display the list in a dropdown.
635
+ * @returns {FDataValidationBuilder} The current instance for method chaining.
565
636
  * @example
566
637
  * ```typescript
567
638
  * const fWorkbook = univerAPI.getActiveWorkbook();
568
639
  * const fWorksheet = fWorkbook.getActiveSheet();
640
+ *
641
+ * // Create a new data validation rule that requires the user to enter a value from the list ['Yes', 'No'] for the range A1:B10
569
642
  * const fRange = fWorksheet.getRange('A1:B10');
570
643
  * const rule = univerAPI.newDataValidation()
571
644
  * .requireValueInList(['Yes', 'No'])
@@ -582,22 +655,25 @@ class E {
582
655
  return this._rule.type = t ? o.LIST_MULTIPLE : o.LIST, this._rule.formula1 = e.join(","), this._rule.formula2 = void 0, this._rule.showDropDown = i != null ? i : !0, this;
583
656
  }
584
657
  /**
585
- * Sets a data validation rule that requires the user to enter a value within a specific range
586
- * The range is defined by an FRange object, which contains the unit ID, sheet name, and cell range
587
- * @param {FRange} range - An FRange object representing the range of values that the user can enter
588
- * @param {boolean} [multiple] - Optional parameter indicating whether the user can select multiple values
589
- * @param {boolean} [showDropdown] - Optional parameter indicating whether to display the list in a dropdown
590
- * @returns {FDataValidationBuilder} The current instance for method chaining
658
+ * Sets a data validation rule that requires the user to enter a value within a specific range.
659
+ * The range is defined by an FRange object, which contains the unit ID, sheet name, and cell range.
660
+ * @param {FRange} range - An FRange object representing the range of values that the user can enter.
661
+ * @param {boolean} [multiple] - Optional parameter indicating whether the user can select multiple values.
662
+ * @param {boolean} [showDropdown] - Optional parameter indicating whether to display the list in a dropdown.
663
+ * @returns {FDataValidationBuilder} The current instance for method chaining.
591
664
  * @example
592
665
  * ```typescript
593
666
  * const fWorkbook = univerAPI.getActiveWorkbook();
594
667
  * const fWorksheet = fWorkbook.getActiveSheet();
668
+ *
669
+ * // Set the values in the range B1:B2
595
670
  * const fRange = fWorksheet.getRange('B1:B2');
596
671
  * fRange.setValues([
597
672
  * ['Yes'],
598
673
  * ['No']
599
674
  * ]);
600
675
  *
676
+ * // Create a new data validation rule that requires the user to enter a value from the range B1:B2 for the range A1:A10
601
677
  * const rule = univerAPI.newDataValidation()
602
678
  * .requireValueInRange(fRange)
603
679
  * .setOptions({
@@ -618,11 +694,11 @@ class E {
618
694
  })}`, this._rule.formula2 = void 0, this._rule.showDropDown = i != null ? i : !0, this;
619
695
  }
620
696
  /**
621
- * Sets whether to allow invalid data and configures the error style
622
- * If invalid data is not allowed, the error style will be set to STOP, indicating that data entry must stop upon encountering an error
623
- * 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
624
- * @param {boolean} allowInvalidData - Whether to allow invalid data
625
- * @returns {FDataValidationBuilder} The current instance for method chaining
697
+ * Sets whether to allow invalid data and configures the error style.
698
+ * If invalid data is not allowed, the error style will be set to STOP, indicating that data entry must stop upon encountering an error.
699
+ * 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.
700
+ * @param {boolean} allowInvalidData - Whether to allow invalid data.
701
+ * @returns {FDataValidationBuilder} The current instance for method chaining.
626
702
  * @example
627
703
  * ```typescript
628
704
  * const fWorkbook = univerAPI.getActiveWorkbook();
@@ -649,9 +725,9 @@ class E {
649
725
  return this._rule.errorStyle = e ? V.WARNING : V.STOP, this;
650
726
  }
651
727
  /**
652
- * Sets whether to allow blank values
653
- * @param {boolean} allowBlank - Whether to allow blank values
654
- * @returns {FDataValidationBuilder} The current instance for method chaining
728
+ * Sets whether to allow blank values.
729
+ * @param {boolean} allowBlank - Whether to allow blank values.
730
+ * @returns {FDataValidationBuilder} The current instance for method chaining.
655
731
  * @example
656
732
  * ```typescript
657
733
  * // Assume current sheet is empty data
@@ -679,13 +755,15 @@ class E {
679
755
  return this._rule.allowBlank = e, this;
680
756
  }
681
757
  /**
682
- * Sets the options for the data validation rule
683
- * @param {Partial<IDataValidationRuleOptions>} options - The options to set for the data validation rule
684
- * @returns {FDataValidationBuilder} The current instance for method chaining
758
+ * Sets the options for the data validation rule.
759
+ * @param {Partial<IDataValidationRuleOptions>} options - The options to set for the data validation rule.
760
+ * @returns {FDataValidationBuilder} The current instance for method chaining.
685
761
  * @example
686
762
  * ```typescript
687
763
  * const fWorkbook = univerAPI.getActiveWorkbook();
688
764
  * const fWorksheet = fWorkbook.getActiveSheet();
765
+ *
766
+ * // Create a new data validation rule that requires the user to enter a value from the list ['Yes', 'No'] for the range A1:B10
689
767
  * const fRange = fWorksheet.getRange('A1:B10');
690
768
  * const rule = univerAPI.newDataValidation()
691
769
  * .requireValueInList(['Yes', 'No'])
@@ -899,12 +977,15 @@ class _ {
899
977
  * ```typescript
900
978
  * const fWorkbook = univerAPI.getActiveWorkbook();
901
979
  * const fWorksheet = fWorkbook.getActiveSheet();
980
+ *
981
+ * // Create a new data validation rule that requires a number equal to 20 for the range A1:B10
902
982
  * const fRange = fWorksheet.getRange('A1:B10');
903
983
  * const rule = univerAPI.newDataValidation()
904
984
  * .requireNumberEqualTo(20)
905
985
  * .build();
906
986
  * fRange.setDataValidation(rule);
907
987
  *
988
+ * // Change the rule criteria to require a number between 1 and 10
908
989
  * fRange.getDataValidation().setCriteria(
909
990
  * univerAPI.Enum.DataValidationType.DECIMAL,
910
991
  * [univerAPI.Enum.DataValidationOperator.BETWEEN, '1', '10']
@@ -935,12 +1016,15 @@ class _ {
935
1016
  * ```typescript
936
1017
  * const fWorkbook = univerAPI.getActiveWorkbook();
937
1018
  * const fWorksheet = fWorkbook.getActiveSheet();
1019
+ *
1020
+ * // Create a new data validation rule that requires a number equal to 20 for the range A1:B10
938
1021
  * const fRange = fWorksheet.getRange('A1:B10');
939
1022
  * const rule = univerAPI.newDataValidation()
940
1023
  * .requireNumberEqualTo(20)
941
1024
  * .build();
942
1025
  * fRange.setDataValidation(rule);
943
1026
  *
1027
+ * // Supplement the rule with additional options
944
1028
  * fRange.getDataValidation().setOptions({
945
1029
  * allowBlank: true,
946
1030
  * showErrorMessage: true,
@@ -969,12 +1053,15 @@ class _ {
969
1053
  * ```typescript
970
1054
  * const fWorkbook = univerAPI.getActiveWorkbook();
971
1055
  * const fWorksheet = fWorkbook.getActiveSheet();
1056
+ *
1057
+ * // Create a new data validation rule that requires a number equal to 20 for the range A1:B10
972
1058
  * const fRange = fWorksheet.getRange('A1:B10');
973
1059
  * const rule = univerAPI.newDataValidation()
974
1060
  * .requireNumberEqualTo(20)
975
1061
  * .build();
976
1062
  * fRange.setDataValidation(rule);
977
1063
  *
1064
+ * // Change the range to C1:D10
978
1065
  * const newRuleRange = fWorksheet.getRange('C1:D10');
979
1066
  * fRange.getDataValidation().setRanges([newRuleRange]);
980
1067
  * ```
@@ -996,12 +1083,15 @@ class _ {
996
1083
  * ```typescript
997
1084
  * const fWorkbook = univerAPI.getActiveWorkbook();
998
1085
  * const fWorksheet = fWorkbook.getActiveSheet();
1086
+ *
1087
+ * // Create a new data validation rule that requires a number equal to 20 for the range A1:B10
999
1088
  * const fRange = fWorksheet.getRange('A1:B10');
1000
1089
  * const rule = univerAPI.newDataValidation()
1001
1090
  * .requireNumberEqualTo(20)
1002
1091
  * .build();
1003
1092
  * fRange.setDataValidation(rule);
1004
1093
  *
1094
+ * // Delete the data validation rule
1005
1095
  * fRange.getDataValidation().delete();
1006
1096
  * ```
1007
1097
  */