How to use the hoek.flatten function in hoek

To help you get started, we’ve selected a few hoek examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ozum / joi18n / node_modules / hapi / lib / plugin.js View on Github external
internals.Plugin.prototype.select = function (/* labels */) {

    var labels = [];
    for (var i = 0, il = arguments.length; i < il; ++i) {
        labels.push(arguments[i]);
    }

    labels = Hoek.flatten(labels);
    return this._select(labels);
};
github arangodb / arangodb / js / node / node_modules / joi / lib / object.js View on Github external
internals.Object.prototype.xor = function () {

    var peers = Hoek.flatten(Array.prototype.slice.call(arguments));
    return this._dependency('xor', null, peers);
};
github arangodb / arangodb / js / node / node_modules / joi / lib / array.js View on Github external
internals.Array.prototype.items = function () {

    var obj = this.clone();

    Hoek.flatten(Array.prototype.slice.call(arguments)).forEach(function (type) {

        type = Cast.schema(type);
        obj._inner.items.push(type);

        if (type._flags.presence === 'required') {
            obj._inner.requireds.push(type);
        }
        else if (type._flags.presence === 'forbidden') {
            obj._inner.exclusions.push(type.optional());
        }
        else {
            obj._inner.inclusions.push(type);
        }
    });

    return obj;
github ozum / joi18n / node_modules / joi / lib / index.js View on Github external
root.extend = function (...args) {

        const extensions = Hoek.flatten(args);
        Hoek.assert(extensions.length > 0, 'You need to provide at least one extension');

        this.assert(extensions, root.extensionsSchema);

        const joi = Object.create(this.any());
        Object.assign(joi, this);
        joi._currentJoi = joi;
        joi._binds = new Set(joi._binds);

        for (let i = 0; i < extensions.length; ++i) {
            let extension = extensions[i];

            if (typeof extension === 'function') {
                extension = extension(joi);
            }
github hapijs / joi / lib / object.js View on Github external
and() {

        const peers = Hoek.flatten(Array.prototype.slice.call(arguments));
        return this._dependency('and', null, peers);
    }
github arangodb / arangodb / js / node / node_modules / joi / lib / any.js View on Github external
internals.Any.prototype._allow = function () {

    var values = Hoek.flatten(Array.prototype.slice.call(arguments));
    for (var i = 0, il = values.length; i < il; ++i) {
        var value = values[i];
        this._invalids.remove(value);
        this._valids.add(value, this._refs);
    }
};
github ozum / joi18n / node_modules / joi / lib / any.js View on Github external
internals.Any.prototype._allow = function () {

    var values = Hoek.flatten(Array.prototype.slice.call(arguments));
    for (var i = 0, il = values.length; i < il; ++i) {
        var value = values[i];

        Hoek.assert(value !== undefined, 'Cannot call allow/valid/invalid with undefined');
        this._invalids.remove(value);
        this._valids.add(value, this._refs);
    }
};
github arangodb / arangodb / js / node / node_modules / joi / lib / object.js View on Github external
internals.Object.prototype.requiredKeys = function (children) {

    children = Hoek.flatten(Array.prototype.slice.call(arguments));
    return this.applyFunctionToChildren(children, 'required');
};
github ozum / joi18n / node_modules / hapi / node_modules / joi / lib / index.js View on Github external
root.extend = function (...args) {

        const extensions = Hoek.flatten(args);
        Hoek.assert(extensions.length > 0, 'You need to provide at least one extension');

        this.assert(extensions, root.extensionsSchema);

        const joi = Object.create(this.any());
        Object.assign(joi, this);

        for (let i = 0; i < extensions.length; ++i) {
            let extension = extensions[i];

            if (typeof extension === 'function') {
                extension = extension(joi);
            }

            this.assert(extension, root.extensionSchema);
github flaviuse / mern-authentication / client / node_modules / joi / lib / types / any / index.js View on Github external
allow(...values) {

        const obj = this.clone();
        values = Hoek.flatten(values);
        for (let i = 0; i < values.length; ++i) {
            const value = values[i];

            Hoek.assert(value !== undefined, 'Cannot call allow/valid/invalid with undefined');
            obj._invalids.remove(value);
            obj._valids.add(value, obj._refs);
        }

        return obj;
    }