@univerjs/sheets-data-validation 0.6.0 → 0.6.1

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.
@@ -6,8 +6,23 @@ import { FDataValidation } from './f-data-validation';
6
6
  * @example
7
7
  * ```typescript
8
8
  * // Set the data validation for cell A1 to require a value from B1:B10
9
- * const range = FRange.create('Sheet1', 'B1:B10');
10
- * const rule = univerAPI.newDataValidation().requireValueInRange(range).build();
9
+ * const fWorkbook = univerAPI.getActiveWorkbook();
10
+ * const fWorksheet = fWorkbook.getActiveSheet();
11
+ * const fRange = fWorksheet.getRange('B1:B2');
12
+ * fRange.setValues([
13
+ * ['Yes'],
14
+ * ['No']
15
+ * ]);
16
+ *
17
+ * const rule = univerAPI.newDataValidation()
18
+ * .requireValueInRange(fRange)
19
+ * .setOptions({
20
+ * allowBlank: false,
21
+ * showErrorMessage: true,
22
+ * error: 'Please enter a value from the list'
23
+ * })
24
+ * .build();
25
+ * const cell = fWorksheet.getRange('A1');
11
26
  * cell.setDataValidation(rule);
12
27
  * ```
13
28
  * @hideconstructor
@@ -20,8 +35,18 @@ export declare class FDataValidationBuilder {
20
35
  * @returns {FDataValidation} A new instance of the FDataValidation class
21
36
  * @example
22
37
  * ```typescript
23
- * const builder = univerAPI.newDataValidation();
24
- * const validation = builder.requireNumberBetween(1, 10).build();
38
+ * const fWorkbook = univerAPI.getActiveWorkbook();
39
+ * const fWorksheet = fWorkbook.getActiveSheet();
40
+ * const fRange = fWorksheet.getRange('A1:B10');
41
+ * const rule = univerAPI.newDataValidation()
42
+ * .requireNumberBetween(1, 10)
43
+ * .setOptions({
44
+ * allowBlank: true,
45
+ * showErrorMessage: true,
46
+ * error: 'Please enter a number between 1 and 10'
47
+ * })
48
+ * .build();
49
+ * fRange.setDataValidation(rule);
25
50
  * ```
26
51
  */
27
52
  build(): FDataValidation;
@@ -30,8 +55,9 @@ export declare class FDataValidationBuilder {
30
55
  * @returns {FDataValidationBuilder} A new instance of the DataValidationBuilder class
31
56
  * @example
32
57
  * ```typescript
33
- * const builder = univerAPI.newDataValidation();
34
- * const copy = builder.requireNumberBetween(1, 10).copy();
58
+ * const builder = univerAPI.newDataValidation().requireNumberBetween(1, 10);
59
+ * const copyBuilder = builder.copy();
60
+ * console.log(copyBuilder);
35
61
  * ```
36
62
  */
37
63
  copy(): FDataValidationBuilder;
@@ -40,8 +66,8 @@ export declare class FDataValidationBuilder {
40
66
  * @returns {boolean} True if invalid data is allowed, False otherwise
41
67
  * @example
42
68
  * ```typescript
43
- * const builder = univerAPI.newDataValidation();
44
- * const allowsInvalid = builder.getAllowInvalid();
69
+ * const builder = univerAPI.newDataValidation().requireNumberBetween(1, 10);
70
+ * console.log(builder.getAllowInvalid());
45
71
  * ```
46
72
  */
47
73
  getAllowInvalid(): boolean;
@@ -51,7 +77,13 @@ export declare class FDataValidationBuilder {
51
77
  * @example
52
78
  * ```typescript
53
79
  * const builder = univerAPI.newDataValidation();
54
- * const type = builder.getCriteriaType();
80
+ * console.log(builder.getCriteriaType());
81
+ *
82
+ * builder.requireNumberBetween(1, 10);
83
+ * console.log(builder.getCriteriaType());
84
+ *
85
+ * builder.requireValueInList(['Yes', 'No']);
86
+ * console.log(builder.getCriteriaType());
55
87
  * ```
56
88
  */
57
89
  getCriteriaType(): DataValidationType | string;
@@ -60,8 +92,12 @@ export declare class FDataValidationBuilder {
60
92
  * @returns {[string | undefined, string | undefined, string | undefined]} An array containing the operator, formula1, and formula2 values
61
93
  * @example
62
94
  * ```typescript
63
- * const builder = univerAPI.newDataValidation();
95
+ * const builder = univerAPI.newDataValidation().requireNumberBetween(1, 10);
64
96
  * const [operator, formula1, formula2] = builder.getCriteriaValues();
97
+ * console.log(operator, formula1, formula2);
98
+ *
99
+ * builder.requireValueInList(['Yes', 'No']);
100
+ * console.log(builder.getCriteriaValues());
65
101
  * ```
66
102
  */
67
103
  getCriteriaValues(): [string | undefined, string | undefined, string | undefined];
@@ -70,8 +106,11 @@ export declare class FDataValidationBuilder {
70
106
  * @returns {string | undefined} Returns the help text information. If there is no error message, it returns an undefined value
71
107
  * @example
72
108
  * ```typescript
73
- * const builder = univerAPI.newDataValidation();
74
- * const helpText = builder.getHelpText();
109
+ * const builder = univerAPI.newDataValidation().setOptions({
110
+ * showErrorMessage: true,
111
+ * error: 'Please enter a valid value'
112
+ * });
113
+ * console.log(builder.getHelpText()); // 'Please enter a valid value'
75
114
  * ```
76
115
  */
77
116
  getHelpText(): string | undefined;
@@ -82,8 +121,22 @@ export declare class FDataValidationBuilder {
82
121
  * @returns {FDataValidationBuilder} The current instance for method chaining
83
122
  * @example
84
123
  * ```typescript
85
- * const builder = univerAPI.newDataValidation();
86
- * const rule = builder.requireCheckbox('Yes', 'No').build();
124
+ * const fWorkbook = univerAPI.getActiveWorkbook();
125
+ * const fWorksheet = fWorkbook.getActiveSheet();
126
+ *
127
+ * // Set the data validation for cell A1:A10 to require a checkbox with default 1 and 0 values
128
+ * const fRange = fWorksheet.getRange('A1:A10');
129
+ * const rule = univerAPI.newDataValidation()
130
+ * .requireCheckbox()
131
+ * .build();
132
+ * fRange.setDataValidation(rule);
133
+ *
134
+ * // Set the data validation for cell B1:B10 to require a checkbox with 'Yes' and 'No' values
135
+ * const fRange2 = fWorksheet.getRange('B1:B10');
136
+ * const rule2 = univerAPI.newDataValidation()
137
+ * .requireCheckbox('Yes', 'No')
138
+ * .build();
139
+ * fRange2.setDataValidation(rule2);
87
140
  * ```
88
141
  */
89
142
  requireCheckbox(checkedValue?: string, uncheckedValue?: string): FDataValidationBuilder;
@@ -93,8 +146,20 @@ export declare class FDataValidationBuilder {
93
146
  * @returns {FDataValidationBuilder} The current instance for method chaining
94
147
  * @example
95
148
  * ```typescript
96
- * const builder = univerAPI.newDataValidation();
97
- * const rule = builder.requireDateAfter(new Date('2024-01-01')).build();
149
+ * const fWorkbook = univerAPI.getActiveWorkbook();
150
+ * const fWorksheet = fWorkbook.getActiveSheet();
151
+ * const fRange = fWorksheet.getRange('A1:B2');
152
+ * fRange.setValues([
153
+ * ['2024-01-01', '2024-12-31'],
154
+ * ['2025-01-01', '2025-12-31']
155
+ * ]);
156
+ * const rule = univerAPI.newDataValidation()
157
+ * .requireDateAfter(new Date('2025-01-01'))
158
+ * .build();
159
+ * fRange.setDataValidation(rule);
160
+ *
161
+ * const status = await fRange.getValidatorStatus();
162
+ * console.log(status); // [['invalid', 'invalid', 'invalid', 'valid']]
98
163
  * ```
99
164
  */
100
165
  requireDateAfter(date: Date): FDataValidationBuilder;
@@ -104,8 +169,20 @@ export declare class FDataValidationBuilder {
104
169
  * @returns {FDataValidationBuilder} The current instance for method chaining
105
170
  * @example
106
171
  * ```typescript
107
- * const builder = univerAPI.newDataValidation();
108
- * const rule = builder.requireDateBefore(new Date('2024-12-31')).build();
172
+ * const fWorkbook = univerAPI.getActiveWorkbook();
173
+ * const fWorksheet = fWorkbook.getActiveSheet();
174
+ * const fRange = fWorksheet.getRange('A1:B2');
175
+ * fRange.setValues([
176
+ * ['2024-01-01', '2024-12-31'],
177
+ * ['2025-01-01', '2025-12-31']
178
+ * ]);
179
+ * const rule = univerAPI.newDataValidation()
180
+ * .requireDateBefore(new Date('2025-01-01'))
181
+ * .build();
182
+ * fRange.setDataValidation(rule);
183
+ *
184
+ * const status = await fRange.getValidatorStatus();
185
+ * console.log(status); // [['valid', 'valid', 'invalid', 'invalid']]
109
186
  * ```
110
187
  */
111
188
  requireDateBefore(date: Date): FDataValidationBuilder;
@@ -116,10 +193,20 @@ export declare class FDataValidationBuilder {
116
193
  * @returns {FDataValidationBuilder} The current instance for method chaining
117
194
  * @example
118
195
  * ```typescript
119
- * const builder = univerAPI.newDataValidation();
120
- * const rule = builder
121
- * .requireDateBetween(new Date('2024-01-01'), new Date('2024-12-31'))
196
+ * const fWorkbook = univerAPI.getActiveWorkbook();
197
+ * const fWorksheet = fWorkbook.getActiveSheet();
198
+ * const fRange = fWorksheet.getRange('A1:B2');
199
+ * fRange.setValues([
200
+ * ['2024-01-01', '2024-12-31'],
201
+ * ['2025-01-01', '2025-12-31']
202
+ * ]);
203
+ * const rule = univerAPI.newDataValidation()
204
+ * .requireDateBetween(new Date('2024-06-01'), new Date('2025-06-01'))
122
205
  * .build();
206
+ * fRange.setDataValidation(rule);
207
+ *
208
+ * const status = await fRange.getValidatorStatus();
209
+ * console.log(status); // [['invalid', 'valid', 'valid', 'invalid']]
123
210
  * ```
124
211
  */
125
212
  requireDateBetween(start: Date, end: Date): FDataValidationBuilder;
@@ -129,8 +216,23 @@ export declare class FDataValidationBuilder {
129
216
  * @returns {FDataValidationBuilder} The current instance for method chaining
130
217
  * @example
131
218
  * ```typescript
132
- * const builder = univerAPI.newDataValidation();
133
- * const rule = builder.requireDateEqualTo(new Date('2024-01-01')).build();
219
+ * const fWorkbook = univerAPI.getActiveWorkbook();
220
+ * const fWorksheet = fWorkbook.getActiveSheet();
221
+ * const fRange = fWorksheet.getRange('A1:B2');
222
+ * fRange.setValues([
223
+ * ['2024-01-01', '2024-12-31'],
224
+ * ['2025-01-01', '2025-12-31']
225
+ * ]);
226
+ * const rule = univerAPI.newDataValidation()
227
+ * .requireDateEqualTo(new Date('2025-01-01'))
228
+ * .build();
229
+ * fRange.setDataValidation(rule);
230
+ *
231
+ * const status = await fWorksheet.getRange('A2').getValidatorStatus();
232
+ * console.log(status?.[0]?.[0]); // 'valid'
233
+ *
234
+ * const status2 = await fWorksheet.getRange('B2').getValidatorStatus();
235
+ * console.log(status2?.[0]?.[0]); // 'invalid'
134
236
  * ```
135
237
  */
136
238
  requireDateEqualTo(date: Date): FDataValidationBuilder;
@@ -141,10 +243,20 @@ export declare class FDataValidationBuilder {
141
243
  * @returns {FDataValidationBuilder} The current instance for method chaining
142
244
  * @example
143
245
  * ```typescript
144
- * const builder = univerAPI.newDataValidation();
145
- * const rule = builder
146
- * .requireDateNotBetween(new Date('2024-01-01'), new Date('2024-12-31'))
246
+ * const fWorkbook = univerAPI.getActiveWorkbook();
247
+ * const fWorksheet = fWorkbook.getActiveSheet();
248
+ * const fRange = fWorksheet.getRange('A1:B2');
249
+ * fRange.setValues([
250
+ * ['2024-01-01', '2024-12-31'],
251
+ * ['2025-01-01', '2025-12-31']
252
+ * ]);
253
+ * const rule = univerAPI.newDataValidation()
254
+ * .requireDateNotBetween(new Date('2024-06-01'), new Date('2025-06-01'))
147
255
  * .build();
256
+ * fRange.setDataValidation(rule);
257
+ *
258
+ * const status = await fRange.getValidatorStatus();
259
+ * console.log(status); // [['valid', 'invalid', 'invalid', 'valid']]
148
260
  * ```
149
261
  */
150
262
  requireDateNotBetween(start: Date, end: Date): FDataValidationBuilder;
@@ -154,8 +266,20 @@ export declare class FDataValidationBuilder {
154
266
  * @returns {FDataValidationBuilder} The current instance for method chaining
155
267
  * @example
156
268
  * ```typescript
157
- * const builder = univerAPI.newDataValidation();
158
- * const rule = builder.requireDateOnOrAfter(new Date('2024-01-01')).build();
269
+ * const fWorkbook = univerAPI.getActiveWorkbook();
270
+ * const fWorksheet = fWorkbook.getActiveSheet();
271
+ * const fRange = fWorksheet.getRange('A1:B2');
272
+ * fRange.setValues([
273
+ * ['2024-01-01', '2024-12-31'],
274
+ * ['2025-01-01', '2025-12-31']
275
+ * ]);
276
+ * const rule = univerAPI.newDataValidation()
277
+ * .requireDateOnOrAfter(new Date('2025-01-01'))
278
+ * .build();
279
+ * fRange.setDataValidation(rule);
280
+ *
281
+ * const status = await fRange.getValidatorStatus();
282
+ * console.log(status); // [['invalid', 'invalid', 'valid', 'valid']]
159
283
  * ```
160
284
  */
161
285
  requireDateOnOrAfter(date: Date): FDataValidationBuilder;
@@ -165,19 +289,52 @@ export declare class FDataValidationBuilder {
165
289
  * @returns {FDataValidationBuilder} The current instance for method chaining
166
290
  * @example
167
291
  * ```typescript
168
- * const builder = univerAPI.newDataValidation();
169
- * const rule = builder.requireDateOnOrBefore(new Date('2024-12-31')).build();
292
+ * const fWorkbook = univerAPI.getActiveWorkbook();
293
+ * const fWorksheet = fWorkbook.getActiveSheet();
294
+ * const fRange = fWorksheet.getRange('A1:B2');
295
+ * fRange.setValues([
296
+ * ['2024-01-01', '2024-12-31'],
297
+ * ['2025-01-01', '2025-12-31']
298
+ * ]);
299
+ * const rule = univerAPI.newDataValidation()
300
+ * .requireDateOnOrBefore(new Date('2025-01-01'))
301
+ * .build();
302
+ * fRange.setDataValidation(rule);
303
+ *
304
+ * const status = await fRange.getValidatorStatus();
305
+ * console.log(status); // [['valid', 'valid', 'valid', 'invalid']]
170
306
  * ```
171
307
  */
172
308
  requireDateOnOrBefore(date: Date): FDataValidationBuilder;
173
309
  /**
174
310
  * Requires that a custom formula be satisfied
175
- * @param {string} formula - The formula string that needs to be satisfied
311
+ * @param {string} formula - The formula string that needs to be satisfied, formula result should be TRUE or FALSE, and references range will relative offset
176
312
  * @returns {FDataValidationBuilder} The current instance for method chaining
177
313
  * @example
178
314
  * ```typescript
179
- * const builder = univerAPI.newDataValidation();
180
- * const rule = builder.requireFormulaSatisfied('=A1>0').build();
315
+ * const fWorkbook = univerAPI.getActiveWorkbook();
316
+ * const fWorksheet = fWorkbook.getActiveSheet();
317
+ * const cell = fWorksheet.getRange('A1:B2');
318
+ * cell.setValues([
319
+ * [4, 3],
320
+ * [2, 1]
321
+ * ]);
322
+ * const fRange = fWorksheet.getRange('C1:D2');
323
+ * fRange.setValues([
324
+ * [1, 2],
325
+ * [3, 4]
326
+ * ]);
327
+ * const rule = univerAPI.newDataValidation()
328
+ * .requireFormulaSatisfied('=A1>2')
329
+ * .setOptions({
330
+ * showErrorMessage: true,
331
+ * error: 'Please enter a value equal to A1'
332
+ * })
333
+ * .build();
334
+ * fRange.setDataValidation(rule);
335
+ *
336
+ * const status = await fRange.getValidatorStatus();
337
+ * console.log(status); // [['valid', 'valid', 'invalid', 'invalid']]
181
338
  * ```
182
339
  */
183
340
  requireFormulaSatisfied(formula: string): FDataValidationBuilder;
@@ -189,8 +346,18 @@ export declare class FDataValidationBuilder {
189
346
  * @returns {FDataValidationBuilder} The current instance for method chaining
190
347
  * @example
191
348
  * ```typescript
192
- * const builder = univerAPI.newDataValidation();
193
- * const rule = builder.requireNumberBetween(1, 10).build();
349
+ * const fWorkbook = univerAPI.getActiveWorkbook();
350
+ * const fWorksheet = fWorkbook.getActiveSheet();
351
+ * const fRange = fWorksheet.getRange('A1:B10');
352
+ * const rule = univerAPI.newDataValidation()
353
+ * .requireNumberBetween(1, 10)
354
+ * .setOptions({
355
+ * allowBlank: false,
356
+ * showErrorMessage: true,
357
+ * error: 'Please enter a number between 1 and 10'
358
+ * })
359
+ * .build();
360
+ * fRange.setDataValidation(rule);
194
361
  * ```
195
362
  */
196
363
  requireNumberBetween(start: number, end: number, isInteger?: boolean): FDataValidationBuilder;
@@ -201,8 +368,18 @@ export declare class FDataValidationBuilder {
201
368
  * @returns {FDataValidationBuilder} The current instance for method chaining
202
369
  * @example
203
370
  * ```typescript
204
- * const builder = univerAPI.newDataValidation();
205
- * const rule = builder.requireNumberEqualTo(10).build();
371
+ * const fWorkbook = univerAPI.getActiveWorkbook();
372
+ * const fWorksheet = fWorkbook.getActiveSheet();
373
+ * const fRange = fWorksheet.getRange('A1:B10');
374
+ * const rule = univerAPI.newDataValidation()
375
+ * .requireNumberEqualTo(10)
376
+ * .setOptions({
377
+ * allowBlank: false,
378
+ * showErrorMessage: true,
379
+ * error: 'Please enter a number equal to 10'
380
+ * })
381
+ * .build();
382
+ * fRange.setDataValidation(rule);
206
383
  * ```
207
384
  */
208
385
  requireNumberEqualTo(num: number, isInteger?: boolean): FDataValidationBuilder;
@@ -213,8 +390,18 @@ export declare class FDataValidationBuilder {
213
390
  * @returns {FDataValidationBuilder} The current instance for method chaining
214
391
  * @example
215
392
  * ```typescript
216
- * const builder = univerAPI.newDataValidation();
217
- * const rule = builder.requireNumberGreaterThan(10).build();
393
+ * const fWorkbook = univerAPI.getActiveWorkbook();
394
+ * const fWorksheet = fWorkbook.getActiveSheet();
395
+ * const fRange = fWorksheet.getRange('A1:B10');
396
+ * const rule = univerAPI.newDataValidation()
397
+ * .requireNumberGreaterThan(10)
398
+ * .setOptions({
399
+ * allowBlank: false,
400
+ * showErrorMessage: true,
401
+ * error: 'Please enter a number greater than 10'
402
+ * })
403
+ * .build();
404
+ * fRange.setDataValidation(rule);
218
405
  * ```
219
406
  */
220
407
  requireNumberGreaterThan(num: number, isInteger?: boolean): FDataValidationBuilder;
@@ -225,8 +412,18 @@ export declare class FDataValidationBuilder {
225
412
  * @returns {FDataValidationBuilder} The current instance for method chaining
226
413
  * @example
227
414
  * ```typescript
228
- * const builder = univerAPI.newDataValidation();
229
- * const rule = builder.requireNumberGreaterThanOrEqualTo(10).build();
415
+ * const fWorkbook = univerAPI.getActiveWorkbook();
416
+ * const fWorksheet = fWorkbook.getActiveSheet();
417
+ * const fRange = fWorksheet.getRange('A1:B10');
418
+ * const rule = univerAPI.newDataValidation()
419
+ * .requireNumberGreaterThanOrEqualTo(10)
420
+ * .setOptions({
421
+ * allowBlank: false,
422
+ * showErrorMessage: true,
423
+ * error: 'Please enter a number greater than 10 or equal to 10'
424
+ * })
425
+ * .build();
426
+ * fRange.setDataValidation(rule);
230
427
  * ```
231
428
  */
232
429
  requireNumberGreaterThanOrEqualTo(num: number, isInteger?: boolean): FDataValidationBuilder;
@@ -237,8 +434,18 @@ export declare class FDataValidationBuilder {
237
434
  * @returns {FDataValidationBuilder} The current instance for method chaining
238
435
  * @example
239
436
  * ```typescript
240
- * const builder = univerAPI.newDataValidation();
241
- * const rule = builder.requireNumberLessThan(10).build();
437
+ * const fWorkbook = univerAPI.getActiveWorkbook();
438
+ * const fWorksheet = fWorkbook.getActiveSheet();
439
+ * const fRange = fWorksheet.getRange('A1:B10');
440
+ * const rule = univerAPI.newDataValidation()
441
+ * .requireNumberLessThan(10)
442
+ * .setOptions({
443
+ * allowBlank: false,
444
+ * showErrorMessage: true,
445
+ * error: 'Please enter a number less than 10'
446
+ * })
447
+ * .build();
448
+ * fRange.setDataValidation(rule);
242
449
  * ```
243
450
  */
244
451
  requireNumberLessThan(num: number, isInteger?: boolean): FDataValidationBuilder;
@@ -250,8 +457,18 @@ export declare class FDataValidationBuilder {
250
457
  * @returns {FDataValidationBuilder} The current instance for method chaining
251
458
  * @example
252
459
  * ```typescript
253
- * const builder = univerAPI.newDataValidation();
254
- * const rule = builder.requireNumberLessThanOrEqualTo(10).build();
460
+ * const fWorkbook = univerAPI.getActiveWorkbook();
461
+ * const fWorksheet = fWorkbook.getActiveSheet();
462
+ * const fRange = fWorksheet.getRange('A1:B10');
463
+ * const rule = univerAPI.newDataValidation()
464
+ * .requireNumberLessThanOrEqualTo(10)
465
+ * .setOptions({
466
+ * allowBlank: false,
467
+ * showErrorMessage: true,
468
+ * error: 'Please enter a number less than 10 or equal to 10'
469
+ * })
470
+ * .build();
471
+ * fRange.setDataValidation(rule);
255
472
  * ```
256
473
  */
257
474
  requireNumberLessThanOrEqualTo(num: number, isInteger?: boolean): FDataValidationBuilder;
@@ -264,8 +481,18 @@ export declare class FDataValidationBuilder {
264
481
  * @returns {FDataValidationBuilder} The current instance for method chaining
265
482
  * @example
266
483
  * ```typescript
267
- * const builder = univerAPI.newDataValidation();
268
- * const rule = builder.requireNumberNotBetween(1, 10).build();
484
+ * const fWorkbook = univerAPI.getActiveWorkbook();
485
+ * const fWorksheet = fWorkbook.getActiveSheet();
486
+ * const fRange = fWorksheet.getRange('A1:B10');
487
+ * const rule = univerAPI.newDataValidation()
488
+ * .requireNumberNotBetween(1, 10)
489
+ * .setOptions({
490
+ * allowBlank: false,
491
+ * showErrorMessage: true,
492
+ * error: 'Please enter a number not between 1 and 10'
493
+ * })
494
+ * .build();
495
+ * fRange.setDataValidation(rule);
269
496
  * ```
270
497
  */
271
498
  requireNumberNotBetween(start: number, end: number, isInteger?: boolean): FDataValidationBuilder;
@@ -277,8 +504,18 @@ export declare class FDataValidationBuilder {
277
504
  * @returns {FDataValidationBuilder} The current instance for method chaining
278
505
  * @example
279
506
  * ```typescript
280
- * const builder = univerAPI.newDataValidation();
281
- * const rule = builder.requireNumberNotEqualTo(10).build();
507
+ * const fWorkbook = univerAPI.getActiveWorkbook();
508
+ * const fWorksheet = fWorkbook.getActiveSheet();
509
+ * const fRange = fWorksheet.getRange('A1:B10');
510
+ * const rule = univerAPI.newDataValidation()
511
+ * .requireNumberNotEqualTo(10)
512
+ * .setOptions({
513
+ * allowBlank: false,
514
+ * showErrorMessage: true,
515
+ * error: 'Please enter a number not equal to 10'
516
+ * })
517
+ * .build();
518
+ * fRange.setDataValidation(rule);
282
519
  * ```
283
520
  */
284
521
  requireNumberNotEqualTo(num: number, isInteger?: boolean): FDataValidationBuilder;
@@ -291,8 +528,18 @@ export declare class FDataValidationBuilder {
291
528
  * @returns {FDataValidationBuilder} The current instance for method chaining
292
529
  * @example
293
530
  * ```typescript
294
- * const builder = univerAPI.newDataValidation();
295
- * const rule = builder.requireValueInList(['Yes', 'No']).build();
531
+ * const fWorkbook = univerAPI.getActiveWorkbook();
532
+ * const fWorksheet = fWorkbook.getActiveSheet();
533
+ * const fRange = fWorksheet.getRange('A1:B10');
534
+ * const rule = univerAPI.newDataValidation()
535
+ * .requireValueInList(['Yes', 'No'])
536
+ * .setOptions({
537
+ * allowBlank: true,
538
+ * showErrorMessage: true,
539
+ * error: 'Please enter a value from the list'
540
+ * })
541
+ * .build();
542
+ * fRange.setDataValidation(rule);
296
543
  * ```
297
544
  */
298
545
  requireValueInList(values: string[], multiple?: boolean, showDropdown?: boolean): FDataValidationBuilder;
@@ -305,9 +552,24 @@ export declare class FDataValidationBuilder {
305
552
  * @returns {FDataValidationBuilder} The current instance for method chaining
306
553
  * @example
307
554
  * ```typescript
308
- * const builder = univerAPI.newDataValidation();
309
- * const range = FRange.create('Sheet1', 'B1:B10');
310
- * const rule = builder.requireValueInRange(range).build();
555
+ * const fWorkbook = univerAPI.getActiveWorkbook();
556
+ * const fWorksheet = fWorkbook.getActiveSheet();
557
+ * const fRange = fWorksheet.getRange('B1:B2');
558
+ * fRange.setValues([
559
+ * ['Yes'],
560
+ * ['No']
561
+ * ]);
562
+ *
563
+ * const rule = univerAPI.newDataValidation()
564
+ * .requireValueInRange(fRange)
565
+ * .setOptions({
566
+ * allowBlank: false,
567
+ * showErrorMessage: true,
568
+ * error: 'Please enter a value from the list'
569
+ * })
570
+ * .build();
571
+ * const cell = fWorksheet.getRange('A1');
572
+ * cell.setDataValidation(rule);
311
573
  * ```
312
574
  */
313
575
  requireValueInRange(range: FRange, multiple?: boolean, showDropdown?: boolean): FDataValidationBuilder;
@@ -319,8 +581,24 @@ export declare class FDataValidationBuilder {
319
581
  * @returns {FDataValidationBuilder} The current instance for method chaining
320
582
  * @example
321
583
  * ```typescript
322
- * const builder = univerAPI.newDataValidation();
323
- * const rule = builder.setAllowInvalid(true).build();
584
+ * const fWorkbook = univerAPI.getActiveWorkbook();
585
+ * const fWorksheet = fWorkbook.getActiveSheet();
586
+ *
587
+ * // Set the data validation for cell A1:B2 to allow invalid data, so A1:B2 will display a warning when invalid data is entered
588
+ * const fRange = fWorksheet.getRange('A1:B2');
589
+ * const rule = univerAPI.newDataValidation()
590
+ * .requireValueInList(['Yes', 'No'])
591
+ * .setAllowInvalid(true)
592
+ * .build();
593
+ * fRange.setDataValidation(rule);
594
+ *
595
+ * // Set the data validation for cell C1:D2 to not allow invalid data, so C1:D2 will stop data entry when invalid data is entered
596
+ * const fRange2 = fWorksheet.getRange('C1:D2');
597
+ * const rule2 = univerAPI.newDataValidation()
598
+ * .requireValueInList(['Yes', 'No'])
599
+ * .setAllowInvalid(false)
600
+ * .build();
601
+ * fRange2.setDataValidation(rule2);
324
602
  * ```
325
603
  */
326
604
  setAllowInvalid(allowInvalidData: boolean): FDataValidationBuilder;
@@ -330,8 +608,25 @@ export declare class FDataValidationBuilder {
330
608
  * @returns {FDataValidationBuilder} The current instance for method chaining
331
609
  * @example
332
610
  * ```typescript
333
- * const builder = univerAPI.newDataValidation();
334
- * const rule = builder.setAllowBlank(true).build();
611
+ * // Assume current sheet is empty data
612
+ * const fWorkbook = univerAPI.getActiveWorkbook();
613
+ * const fWorksheet = fWorkbook.getActiveSheet();
614
+ *
615
+ * // Set the data validation for cell A1:B2 to allow blank values
616
+ * const fRange = fWorksheet.getRange('A1:B2');
617
+ * const rule = univerAPI.newDataValidation()
618
+ * .requireValueInList(['Yes', 'No'])
619
+ * .setAllowBlank(true)
620
+ * .build();
621
+ * fRange.setDataValidation(rule);
622
+ *
623
+ * // Set the data validation for cell C1:D2 to not allow blank values
624
+ * const fRange2 = fWorksheet.getRange('C1:D2');
625
+ * const rule2 = univerAPI.newDataValidation()
626
+ * .requireValueInList(['Yes', 'No'])
627
+ * .setAllowBlank(false)
628
+ * .build();
629
+ * fRange2.setDataValidation(rule2);
335
630
  * ```
336
631
  */
337
632
  setAllowBlank(allowBlank: boolean): FDataValidationBuilder;
@@ -341,12 +636,18 @@ export declare class FDataValidationBuilder {
341
636
  * @returns {FDataValidationBuilder} The current instance for method chaining
342
637
  * @example
343
638
  * ```typescript
344
- * const builder = univerAPI.newDataValidation();
345
- * const rule = builder.setOptions({
346
- * allowBlank: true,
347
- * showErrorMessage: true,
348
- * error: 'Please enter a valid value'
349
- * }).build();
639
+ * const fWorkbook = univerAPI.getActiveWorkbook();
640
+ * const fWorksheet = fWorkbook.getActiveSheet();
641
+ * const fRange = fWorksheet.getRange('A1:B10');
642
+ * const rule = univerAPI.newDataValidation()
643
+ * .requireValueInList(['Yes', 'No'])
644
+ * .setOptions({
645
+ * allowBlank: true,
646
+ * showErrorMessage: true,
647
+ * error: 'Please enter a value from the list'
648
+ * })
649
+ * .build();
650
+ * fRange.setDataValidation(rule);
350
651
  * ```
351
652
  */
352
653
  setOptions(options: Partial<IDataValidationRuleOptions>): this;