Skip to content

Commit 47d356b

Browse files
committed
Merge branch 'develop'
2 parents 33b950a + 9661369 commit 47d356b

File tree

1 file changed

+27
-53
lines changed

1 file changed

+27
-53
lines changed

README.md

Lines changed: 27 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -37,83 +37,57 @@ Below is an example demonstrating how to use the PHP Prompts library to create i
3737
This step is optional but provides context for the user.
3838

3939
```php
40-
$prompt->setTitle("Your prompt title");
41-
$prompt->setDescription("Your prompt description, lorem ipsum dolor");
40+
$inp->setTitle("Hello there!");
41+
$inp->setDescription("We need your contact information to stay in touch, thank you.");
4242
```
4343

4444
3. **Define the Prompts**
4545

4646
Define the prompts and their respective settings, including type, message, validation rules, and error messages.
4747

4848
```php
49-
$prompt->set([
50-
"firstname" => [
49+
$inp->set([
50+
"name" => [
5151
"type" => "text",
52-
"message" => "First name",
52+
"message" => "Full Name",
5353
"validate" => [
54-
"length" => [1, 200]
55-
],
56-
"error" => "Required"
57-
],
58-
"lastname" => [
59-
"type" => "text",
60-
"message" => "Last name",
61-
"default" => "Doe",
62-
"validate" => function($input) {
63-
return (strlen($input) >= 3);
64-
},
65-
"error" => "The last name must be more than 2 characters!"
54+
"length" => [1,200]
55+
]
6656
],
6757
"email" => [
6858
"type" => "text",
6959
"message" => "Email",
7060
"validate" => [
71-
"length" => [1, 200],
61+
"length" => [1,200],
7262
"email" => []
73-
]
63+
],
64+
"error" => "The email address entered is not valid."
7465
],
75-
"ssl" => [
66+
"newsletter" => [
7667
"type" => "toggle",
77-
"message" => "Do you want SSL?",
68+
"message" => "Receive newsletter?",
7869
],
79-
"message" => [
80-
"type" => "message",
81-
"message" => "Lorem ipsum dolor",
82-
],
83-
"select" => [
70+
"method" => [
8471
"type" => "select",
85-
"message" => "Select an item below",
72+
"message" => "Preferred contact method?",
8673
"items" => [
87-
"Lorem 1",
88-
"Lorem 2",
89-
"Lorem 3"
74+
"email" => "Email",
75+
"phone" => "Phone",
76+
"text" => "Text",
77+
"mail" => "Mail"
9078
],
9179
],
92-
"keyword" => [
93-
"type" => "list",
94-
"message" => "Keywords",
95-
"validate" => [
96-
"length" => [1, 200],
97-
"number" => []
98-
],
99-
"error" => function($errorType, $input, $row) {
100-
if ($errorType === "length") {
101-
return "Is required";
102-
}
103-
return "Must be a number";
104-
}
105-
],
106-
"password" => [
107-
"type" => "password",
108-
"message" => "Password",
80+
"phone" => [
81+
"type" => "text",
82+
"message" => "Phone",
10983
"validate" => [
110-
"length" => [1, 200]
84+
"length" => [1,30],
85+
"phone" => []
11186
]
11287
],
11388
"confirm" => [
11489
"type" => "confirm",
115-
"message" => "Do you wish to continue?",
116-
"confirm" => "Continuing..."
90+
"message" => "Do you wish to continue?"
11791
]
11892
]);
11993
```
@@ -138,11 +112,11 @@ Below is an example demonstrating how to use the PHP Prompts library to create i
138112

139113
2. **message**
140114
- **Description**: The message or question displayed to the user.
141-
- **Example**: `"message" => "Enter your first name"`
115+
- **Example**: `"message" => "Enter your full name"`
142116

143117
3. **default**
144118
- **Description**: A default value for the prompt, used if the user does not provide input.
145-
- **Example**: `"default" => "Doe"`
119+
- **Example**: `"default" => "Your default value"`
146120

147121
4. **items**
148122
- **Description**: An array of items to choose from, used with `select` type prompts.
@@ -163,7 +137,7 @@ Below is an example demonstrating how to use the PHP Prompts library to create i
163137
- **Description**: Error message or function to display when validation fails.
164138
- **Examples**:
165139
- Static message: `"error" => "Input is required"`
166-
- Function:
140+
- Custom function error:
167141
```php
168142
"error" => function($errorType, $input, $row) {
169143
if ($errorType === "length") {

0 commit comments

Comments
 (0)