Created
December 2, 2017 16:06
-
-
Save WeiChiaChang/a6d143a387cab9014c78caab3da464d4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var questions = [ | |
{ | |
type: 'confirm', | |
name: 'toBeDelivered', | |
message: 'Is this for delivery?', | |
default: false | |
}, | |
{ | |
type: 'input', | |
name: 'phone', | |
message: "What's your phone number?", | |
validate: function(value) { | |
var pass = value.match( | |
/^([01]{1})?[-.\s]?\(?(\d{3})\)?[-.\s]?(\d{3})[-.\s]?(\d{4})\s?((?:#|ext\.?\s?|x\.?\s?){1}(?:\d+)?)?$/i | |
); | |
if (pass) { | |
return true; | |
} | |
return 'Please enter a valid phone number'; | |
} | |
}, | |
{ | |
type: 'list', | |
name: 'size', | |
message: 'What size do you need?', | |
choices: ['Large', 'Medium', 'Small'], | |
filter: function(val) { | |
return val.toLowerCase(); | |
} | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment