1 |
|
2 | const EMAIL_REGEX = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
3 |
|
4 | const REPLY = {
|
5 | name: 'handleMessage',
|
6 | type: 'list',
|
7 | message: 'Options',
|
8 | choices: [
|
9 | {
|
10 | name: 'Back',
|
11 | value: 'back'
|
12 | }, {
|
13 | name: 'Reply',
|
14 | value: 'reply'
|
15 | }, {
|
16 | name: 'Delete',
|
17 | value: 'delete'
|
18 | }, {
|
19 | name: 'Home',
|
20 | value: 'home'
|
21 | }, {
|
22 | name: 'Exit',
|
23 | value: 'exit'
|
24 | }
|
25 | ]
|
26 | }
|
27 |
|
28 | const HOME = {
|
29 | name: 'handleMain',
|
30 | type: 'list',
|
31 | message: 'Home',
|
32 | choices: [
|
33 | { name: 'Inbox', value: 'inbox' },
|
34 | { name: 'Settings', value: 'settings' },
|
35 | { name: 'Re-Authorize', value: 'authorize' },
|
36 | { name: 'Exit', value: 'exit' }
|
37 | ]
|
38 | }
|
39 |
|
40 | const CREATE = [{
|
41 | type: 'input',
|
42 | name: 'recipient',
|
43 | message: 'Recipient',
|
44 | validate (answer) {
|
45 | if (EMAIL_REGEX.test(answer)) {
|
46 | return true
|
47 | }
|
48 | return 'Not a valid email :('
|
49 | }
|
50 | }, {
|
51 | type: 'input',
|
52 | name: 'subject',
|
53 | message: 'Subject',
|
54 | validate: (answer) => {
|
55 | if (answer.length < 1) {
|
56 | return 'Cannot be blank!'
|
57 | }
|
58 | return true
|
59 | }
|
60 | }, {
|
61 | type: 'input',
|
62 | name: 'text',
|
63 | message: 'Message',
|
64 | validate: (answer) => {
|
65 | if (answer.length < 1) {
|
66 | return 'Cannot be blank!'
|
67 | }
|
68 | return true
|
69 | }
|
70 | }]
|
71 |
|
72 | module.exports = {
|
73 | REPLY,
|
74 | HOME,
|
75 | CREATE
|
76 | }
|