File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 8
8
$ itemCallable = function (CliMenu $ menu ) {
9
9
$ result = $ menu ->askPassword ()
10
10
->setPlaceholderText ('' )
11
+ ->setValidator (function ($ password ) {
12
+ if ($ password === 'password ' ) {
13
+ $ this ->setValidationFailedText ('Password is too weak ' );
14
+ return false ;
15
+ } else if (strlen ($ password ) <= 6 ) {
16
+ $ this ->setValidationFailedText ('Password is not long enough ' );
17
+ return false ;
18
+ }
19
+
20
+ return true ;
21
+ })
11
22
->ask ();
12
23
13
24
var_dump ($ result ->fetch ());
Original file line number Diff line number Diff line change @@ -81,9 +81,11 @@ public function getPlaceholderText() : string
81
81
return $ this ->placeholderText ;
82
82
}
83
83
84
- public function setValidator (callable $ validator ) : void
84
+ public function setValidator (callable $ validator ) : Input
85
85
{
86
86
$ this ->validator = $ validator ;
87
+
88
+ return $ this ;
87
89
}
88
90
89
91
public function ask () : InputResult
You can’t perform that action at this time.
0 commit comments