How to use the optionalArray function from assert-plus

Find comprehensive JavaScript assert-plus.optionalArray code examples handpicked from public code repositorys.

153
154
155
156
157
158
159
160
161
162
 *      - @param failOnEmptyValue {Boolean} Optional - If true, throws an error
 *        if a given key's value is the empty string. Default is false.
 */
function _parseKeyValue(kv, validKeys, options) {
    assert.string(kv, 'kv');
    assert.optionalArray(validKeys, 'validKeys');
    assert.optionalObject(options, 'options');
    options = options || {};
    assert.optionalBool(options.disableTypeConversions,
        'options.disableTypeConversions');
fork icon38
star icon55
watch icon41

1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
CloudApi.prototype.createMachine = function createMachine(options, callback) {
    assert.object(options, 'options');
    assert.optionalString(options.name, 'options.name');
    assert.uuid(options.image, 'options.image');
    assert.uuid(options.package, 'options.package');
    assert.optionalArray(options.networks, 'options.networks');
    // TODO: assert the other fields
    assert.func(callback, 'callback');


    // XXX how does options.networks array work here?
fork icon38
star icon55
watch icon41

+ 6 other calls in file

235
236
237
238
239
240
241
242
243
244
245
246
247
};




PGClient.prototype.query = function clientQuery(sql, args) {
    assert.string(sql, 'sql');
    assert.optionalArray(args, 'args');


    // Clean up whitespace so queries are normalized to DTrace
    sql = sql.replace(/(\r\n|\n|\r)/gm, '').replace(/\s+/, ' ');

fork icon21
star icon60
watch icon0

517
518
519
520
521
522
523
524
525
526
func: function createOne(role, nextRole) {
    assert.string(role.name, 'role.name');
    assert.optionalArrayOfObject(role.members, 'role.members');
    assert.optionalArrayOfString(role.default_members,
        'role.default_members');
    assert.optionalArray(role.policies,
        'role.policies');

    t.comment('creating role ' + role.name);
    ctx.smartdcClient.createRole(role, function (err) {
fork icon16
star icon13
watch icon34

75
76
77
78
79
80
81
82
83
84
assert.number(version, 'version');
assert.object(volumeParams, 'volumeParams');
assert.uuid(storageVmUuid, 'storageVmUuid');
assert.object(billingPackage, 'billingPackage');
assert.string(billingPackage.uuid, 'billingPackage.uuid');
assert.optionalArray(affinity, 'affinity');
assert.uuid(CONFIG.nfsServerImageUuid, 'CONFIG.nfsServerImageUuid');
assert.uuid(CONFIG.nfsServerImageUuid2, 'CONFIG.nfsServerImageUuid2');

var nfsExportsDirName = volumeUtils.NFS_SHARED_VOLUME_EXPORTS_DIRNAME;
fork icon6
star icon8
watch icon0

3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
maAdm.prototype.getDeployedInstanceMetadataJson = function(args, callback) {
    var self, rv;
    var instuuids, fields;


    assertplus.object(args, 'args');
    assertplus.optionalArray(args.fields, 'args.fields');
    assertplus.string(args.svcname, 'args.svcname');
    assertplus.optionalBool(args.doall, 'args.doall');


    self = this;
fork icon13
star icon7
watch icon42

159
160
161
162
163
164
165
166
167
mod_assert.string(pluginObj.name, 'pluginObj.name');
mod_assert.string(pluginObj.path, 'pluginObj.path');
mod_assert.number(pluginObj.timeout,
    'pluginObj.timeout');
mod_assert.number(pluginObj.ttl, 'pluginObj.ttl');
mod_assert.optionalArray(pluginObj.vms,
    'pluginObj.vms');

plugins.push(pluginObj);
fork icon8
star icon3
watch icon0

202
203
204
205
206
207
208
209
210
211
212
 * Shared test code for after API list methods are called
 */
function afterAPIlist(t, opts, callback, err, obj, res) {
    assert.string(opts.type, 'opts.type');
    assert.string(opts.id, 'opts.id');
    assert.optionalArray(opts.present, 'opts.present');


    var desc = opts.desc ? (' ' + opts.desc) : '';
    var id = opts.id;
    var type = opts.type;
fork icon6
star icon0
watch icon0

41
42
43
44
45
46
47
48
49
50
var spanId = uuid.v4();
var traceId;

assert.string(name, 'name');
assert.object(fields, 'fields');
assert.optionalArray(fields.references, 'fields.references');

// First see if we have a parent, if so get its Ctx
if (fields.references) {
    // having .references means we're either a childOf or followsFrom
fork icon4
star icon0
watch icon0

90
91
92
93
94
95
96
97
98
99
assert.string(config.staticLabels.instance, 'config.staticLabels.instance');
assert.string(config.staticLabels.server, 'config.staticLabels.server');
assert.string(config.staticLabels.service, 'config.staticLabels.service');
assert.optionalObject(config.metricOpts, 'config.metricOpts');
if (config.metricOpts !== undefined) {
    assert.optionalArray(
        config.metricOpts.buckets,
        'config.metricOpts.buckets'
    );
    assert.optionalObject(
fork icon3
star icon0
watch icon0