How to use the string function from assert-plus

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

253
254
255
256
257
258
259
260
261
262
263
264




function jobWait(opts, cb) {
    assert.object(opts, 'options');
    assert.object(opts.client, 'options.client');
    assert.string(opts.id, 'options.id');
    assert.object(opts.opts, 'options.opts');
    assert.optionalObject(opts.baropts, 'options.baropts');
    assert.optionalBool(opts.catOutputOnError, 'options.catOutputOnError');
    assert.optionalFunc(cb, 'callback');
fork icon41
star icon75
watch icon57

+ 15 other calls in file

3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
 *
 */
MantaClient.prototype.createUpload = function createUpload(p, opts, cb) {
    assert.string(p, 'path');
    assert.object(opts, 'options');
    assert.string(opts.account, 'opts.account');
    assert.optionalObject(opts.headers, 'opts.headers');
    assert.optionalNumber(opts.copies, 'opts.copies');
    assert.optionalNumber(opts.size, 'opts.size');
    assert.optionalString(opts.md5, 'opts.md5');
fork icon41
star icon75
watch icon0

+ 85 other calls in file

2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
 */
CloudApi.prototype.getNic =
function getNic(opts, cb) {
    assert.object(opts, 'opts');
    assert.uuid(opts.id, 'opts.id');
    assert.string(opts.mac, 'opts.mac');
    assert.func(cb, 'cb');


    var mac = opts.mac.replace(/:/g, '');
    var endpoint = format('/%s/machines/%s/nics/%s', this.account, opts.id,
fork icon38
star icon55
watch icon0

+ 398 other calls in file

1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
function _makeHttpRequest(opts, cb) {
    var self = this;
    assert.object(opts, 'opts');
    assert.string(opts.method, 'opts.method');
    assert.string(opts.path, 'opts.path');
    assert.string(opts.url, 'opts.url');
    assert.optionalObject(opts.headers, 'opts.headers');
    assert.optionalBool(opts.followRedirects, 'opts.followRedirects');
    assert.optionalNumber(opts.maxRedirects, 'opts.maxRedirects');
    assert.func(cb, 'cb');
fork icon35
star icon59
watch icon0

+ 15 other calls in file

891
892
893
894
895
896
897
898
899
900
901
HttpClient.prototype.basicAuth = function basicAuth(username, password) {
    if (username === false) {
        delete this.headers.authorization;
    } else {
        assert.string(username, 'username');
        assert.string(password, 'password');


        var buffer = new Buffer(username + ':' + password, 'utf8');
        this.headers.authorization = 'Basic ' +
            buffer.toString('base64');
fork icon34
star icon55
watch icon0

+ 7 other calls in file

51
52
53
54
55
56
57
58
59
60
61
function assertObjContent(opts, cb) {
    assert.object(opts.t, 'opts.t');
    assert.object(opts.stream, 'opts.stream');
    assert.object(opts.res, 'opts.res');
    assert.number(opts.code, 'opts.code');
    assert.string(opts.text, 'opts.text');
    assert.optionalString(opts.contentType, 'opts.contentType');
    assert.func(cb, 'cb');


    var res = opts.res;
fork icon16
star icon13
watch icon0

1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
 *   and "records" is an array of objects representing VM objects that need to
 *   be changed to be migrated to version "version".
 */
Moray.prototype.findRecordsToMigrate =
function findRecordsToMigrate(modelName, version, options, callback) {
    assert.string(modelName, 'bucketName');
    assert.number(version, 'version');
    assert.ok(version >= 1, 'version >= 1');
    assert.object(options, 'options');
    assert.func(callback, 'callback');
fork icon20
star icon11
watch icon0

+ 13 other calls in file

56
57
58
59
60
61
62
63
64
65
66
67
68
    });
}


function delegateDatasetSupported(cfg) {
    assert.object(cfg, 'cfg');
    assert.string(cfg.type, 'cfg.type');


    var supported = [ 'smartos', 'lx' ];


    return supported.indexOf(cfg.type) >= 0;
fork icon20
star icon11
watch icon0

32
33
34
35
36
37
38
39
40
41
42
43
});


function runValidationErrorTestCase(t, testCase, callback) {
    assert.object(t, 't');
    assert.object(testCase, 'testCase');
    assert.string(testCase.queryString, 'testCase.queryString');
    assert.object(testCase.expectedErr, 'testCase.expectedErr');
    assert.func(callback, 'callback');


    var listVmsQuery = '/vms?' + testCase.queryString;
fork icon20
star icon11
watch icon0

69
70
71
72
73
74
75
76
77
78
var chan = utils.objCopy(config.channels[i]);
assert.string(chan.name, 'config.channels['+i+'].name');
assert.ok(CHANNEL_NAME_RE.test(chan.name),
    format('invalid channel name: %j, must match %s',
        chan.name, CHANNEL_NAME_RE));
assert.string(chan.description, 'config.channels['+i+'].description');
if (chan.hasOwnProperty('default')) {
    assert.bool(chan.default, 'config.channels['+i+'].default');
    if (defaultChannel) {
        assert.ok(false,
fork icon17
star icon5
watch icon0

2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
    assert.object(user, 'user');
    if (user.account) {
        account = user.account;
    }
}
assert.string(key, 'key');
assert.func(cb, 'callback');
if (account) {
    assert.string(account, 'account');
}
fork icon9
star icon3
watch icon0

+ 137 other calls in file

1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
    });
    return;
}

// Normal file/stream AddImageFile
assert.string(options.compression, 'options.compression');
assert.ok(['string', 'object'].indexOf(typeof (options.file)) !== -1,
    'options.file');
assert.optionalString(options.sha1, 'options.sha1');
assert.optionalNumber(options.size, 'options.size');
fork icon13
star icon2
watch icon36

+ 55 other calls in file

78
79
80
81
82
83
84
85
86
87
 *
 * @param {String} user : the user uuid.
 * @param {Function} callback : call of the form f(err, probegroups).
 */
Amon.prototype.listProbeGroups = function (user, callback) {
    assert.string(user, 'user');
    assert.func(callback, 'callback');
    var path = format('/pub/%s/probegroups', user);
    this.client.get(path, function (err, req, res, obj) {
        if (err) {
fork icon13
star icon2
watch icon0

+ 21 other calls in file

369
370
371
372
373
374
375
376
377
378
379
380
}


function addProperty(state, ntpData, key, value) {
    mod_assert.object(state, 'state');
    mod_assert.object(ntpData, 'ntpData');
    mod_assert.string(key, 'key');
    mod_assert.ok(value !== undefined, 'value');


    var target;

fork icon8
star icon3
watch icon0

+ 5 other calls in file

751
752
753
754
755
756
757
758
759
760
761
762
763




Moray.prototype.putMetadata = function putMetadata(options, callback) {
    assert.object(options, 'options');
    assert.string(options.key, 'options.key');
    assert.string(options.requestId, 'options.requestId');
    assert.optionalBool(this.readOnly, 'this.readOnly');
    assert.func(callback, 'callback');


    if (this.readOnly) {
fork icon6
star icon2
watch icon0

+ 29 other calls in file

1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
 *
 * @param digest {String} The full docker digest.
 * @returns {String} The full 64-character docker id.
 */
function dockerIdFromDigest(digest) {
    assert.string(digest, 'digest');
    var parts = digest.split(':');
    assert.ok(parts.length === 2, 'digest should contain exactly one colon');
    return parts[1];
}
fork icon5
star icon2
watch icon0

+ 3 other calls in file

3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
 *      manifest path) and `filePath` (the saved image file path) keys.
 */
IMGADM.prototype.createImage = function createImage(options, callback) {
    var self = this;
    assert.object(options, 'options');
    assert.string(options.vmUuid, 'options.vmUuid');
    assert.object(options.manifest, 'options.manifest');
    assert.optionalFunc(options.logCb, 'options.logCb');
    assert.optionalString(options.compression, 'options.compression');
    assert.optionalBool(options.incremental, 'options.incremental');
fork icon248
star icon0
watch icon0

+ 77 other calls in file

1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
    return (err);
}




function typeToPg(type) {
    assert.string(type, 'type');


    if (TYPES.hasOwnProperty(type)) {
        return TYPES[type].pg;
    } else {
fork icon21
star icon60
watch icon0

+ 11 other calls in file

1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
 * See also the tests in "test/unit/argvFromLine.test.js".
 *
 * @throws {Error} if there are unbalanced quotes or some other parse failure.
 */
function argvFromLine(line) {
    assert.string(line, 'line');


    var trimmed = line.trim();
    var argv = [];
    var state = 'default';
fork icon38
star icon55
watch icon41

+ 27 other calls in file

228
229
230
231
232
233
234
235
236
237
238
 * @param ctx {Object} The "context".
 * @param cb {Function} `function (err)`
 */
function loadRbacConfig(ctx, cb) {
    assert.object(ctx, 'ctx');
    assert.string(ctx.rbacConfigPath, 'ctx.rbacConfigPath');
    assert.func(cb, 'cb');


    vasync.pipeline({funcs: [
        function readIt(_, next) {
fork icon38
star icon55
watch icon0

+ 2 other calls in file