summaryrefslogtreecommitdiff
path: root/lib/validate.js
blob: c6909d61b388f3e49ba0c0373b23decb7cf6cdf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * mongo-edu
 *
 * Copyright (c) 2014 Przemyslaw Pluta
 * Licensed under the MIT license.
 * https://github.com/przemyslawpluta/mongo-edu/blob/master/LICENSE
 */

var mkdirp = require('mkdirp');

module.exports.init = function init(opt, callback) {

    'use strict';

    var profile = [
        { type: 'input', name: 'user', message: 'MongoDB Uni User Name', default: '', validate: function(value) {
            if (value !== '') { return true; }
            return 'Please enter your MongoDB Uni user name - email address';
        }},
        { type: 'password', message: 'MongoDB Uni Password', name: 'password', validate: function(value) {
            if (value !== '') { return true; }
            return 'Please enter your MongoDB Uni password';
        }}
    ];

    if (opt.u !== '') { profile[0].default = opt.u; }

    mkdirp(opt.d, function mkdirp(err) {
        if (err !== null) { return callback(err); }
        callback(null, profile);
    });

};