Skip to content

Instantly share code, notes, and snippets.

@WeiChiaChang
Created December 2, 2017 16:06
Show Gist options
  • Save WeiChiaChang/a6d143a387cab9014c78caab3da464d4 to your computer and use it in GitHub Desktop.
Save WeiChiaChang/a6d143a387cab9014c78caab3da464d4 to your computer and use it in GitHub Desktop.
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