@@ -423,7 +423,52 @@ $bot->onCommand('hello {name} {age}', HelloCommand::class)
423
423
->where(['name' => '[A-Za-z]+', 'age' => '[0-9]+']);
424
424
```
425
425
426
+ :::info
426
427
By default, parameters are constrained by the default regular expression ` .* ` .
428
+ :::
429
+
430
+ Here is the list of the other available constraints:
431
+
432
+ - ` whereIn(string $parameter, array $values) ` <br />
433
+ The parameter must be contained in the given array.
434
+
435
+ ``` php
436
+ $bot->onCommand('confirm {answer}', ConfirmCommand::class)
437
+ ->whereIn('answer', ['y','n']);
438
+ ```
439
+
440
+ - ` whereAlpha(string $parameter) ` <br />
441
+ The parameter must be entirely alphabetic characters.
442
+
443
+ ``` php
444
+ $bot->onCommand('hello {name}', HelloCommand::class)
445
+ ->whereAlpha('name');
446
+ ```
447
+
448
+ - ` whereNumber(string $parameter) ` <br />
449
+ The parameter must be entirely numeric characters.
450
+
451
+ ``` php
452
+ $bot->onCommand('age {age}', AgeCommand::class)
453
+ ->whereNumber('age');
454
+ ```
455
+
456
+ - ` whereAlphaNumeric(string $parameter) ` <br />
457
+ The parameter must be entirely alpha-numeric characters.
458
+
459
+ ``` php
460
+ $bot->onCommand('hello {name}', HelloCommand::class)
461
+ ->whereAlphaNumeric('name');
462
+ ```
463
+
464
+ You can also use the ` where ` methods in group method:
465
+
466
+ ``` php
467
+ $bot->group(function () use (Nutgram $bot) {
468
+ $bot->onCommand('create {name}', CreateCommand::class);
469
+ $bot->onCommand('delete {name}', DeleteCommand::class);
470
+ })->whereAlpha('name');
471
+ ```
427
472
428
473
### ` registerCommand `
429
474
0 commit comments