How to use the @hapi/joi.func function in @hapi/joi

To help you get started, we’ve selected a few @hapi/joi 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 johnbrett / hapi-auth-bearer-token / lib / index.js View on Github external
// Declare Internals

const internals = {};

internals.defaults = {
    accessTokenName: 'access_token',
    allowQueryToken: false,
    allowCookieToken: false,
    allowMultipleHeaders: false,
    allowChaining: false,
    tokenType: 'Bearer',
    unauthorized: Boom.unauthorized
};

internals.schema = Joi.object().keys({
    validate: Joi.func().required(),
    accessTokenName: Joi.string().required(),
    allowQueryToken: Joi.boolean(),
    allowCookieToken: Joi.boolean(),
    allowMultipleHeaders: Joi.boolean(),
    allowChaining: Joi.boolean(),
    tokenType: Joi.string().required(),
    unauthorized: Joi.func()
});

internals.implementation = (server, options) => {

    Hoek.assert(options, 'Missing bearer auth strategy options');

    const settings = Hoek.applyToDefaults(internals.defaults, options);
    Joi.assert(settings, internals.schema);
github hapijs / h2o2 / lib / index.js View on Github external
request: Wreck.request.bind(Wreck),
        parseCacheControl: Wreck.parseCacheControl.bind(Wreck)
    },
    xforward: false,
    passThrough: false,
    redirects: false,
    timeout: 1000 * 60 * 3, // Timeout request after 3 minutes
    localStatePassThrough: false,   // Pass cookies defined by the server upstream
    maxSockets: Infinity,
    downstreamResponseTime: false
};


internals.schema = Joi.object({
    httpClient: Joi.object({
        request: Joi.func(),
        parseCacheControl: Joi.func()
    }),
    host: Joi.string(),
    port: Joi.number().integer(),
    protocol: Joi.string().valid('http', 'https', 'http:', 'https:'),
    uri: Joi.string(),
    passThrough: Joi.boolean(),
    localStatePassThrough: Joi.boolean(),
    acceptEncoding: Joi.boolean().when('passThrough', { is: true, otherwise: Joi.forbidden() }),
    rejectUnauthorized: Joi.boolean(),
    xforward: Joi.boolean(),
    redirects: Joi.number().min(0).integer().allow(false),
    timeout: Joi.number().integer(),
    mapUri: Joi.func(),
    onResponse: Joi.func(),
    onRequest: Joi.func(),
github react-native-community / cli / packages / cli / src / tools / config / schema.ts View on Github external
params: t
          .array()
          .items(
            t.object({
              name: t.string(),
              type: t.string(),
              message: t.string(),
            }),
          )
          .default([]),
      })
      .default(),
    platforms: map(
      t.string(),
      t.object({
        dependencyConfig: t.func(),
        projectConfig: t.func(),
        linkConfig: t.func(),
      }),
    ).default({}),
    commands: t
      .array()
      .items(command)
      .default([]),
  })
  .unknown(true)
  .default();

/**
 * Schema for ProjectConfigT
 */
export const projectConfig = t
github hapipal / lalalambda / lib / hapi.js View on Github external
const handler = others.handler || options.handler;
        delete options.handler;

        lambdas.set(id, {
            id,
            handler,
            server,
            settings: options
        });
    });
};

internals.lambdaSchema = Joi.object({
    id: Joi.string().required(),
    handler: Joi.func(),
    options: Joi.object().default({}).unknown().keys({
        handler: Joi.func()
    })
})
    .xor('handler', 'options.handler');

internals.maybeLambdaifyRoute = (server, route) => {

    const {
        method,
        path,
        params,
        fingerprint,
        public: {
            settings: { id, plugins, cors }
        }
github hydra-newmedia / hapi-sentry / schema.js View on Github external
'use strict';

const { Severity } = require('@sentry/node');
const joi = require('@hapi/joi');

const levels = Object.values(Severity).filter(level => typeof level === 'string')
  || ['fatal', 'error', 'warning', 'log', 'info', 'debug', 'critical'];

const sentryClient = joi.object().keys({
  configureScope: joi.func().minArity(1),
  Scope: joi.func().required(),
  Handlers: joi.object().keys({
    parseRequest: joi.func().minArity(2).required(),
  }).unknown().required(),
  withScope: joi.func().minArity(1).required(),
  captureException: joi.func().minArity(1).required(),
}).unknown();

const sentryOptions = joi.object().keys({
  dsn: joi.string().uri().allow(false).required(),
}).unknown();

module.exports = joi.object().keys({
  baseUri: joi.string().uri(),
  trackUser: joi.boolean().default(true),
  scope: joi.object().keys({
    tags: joi.array().items(joi.object().keys({
github cube-js / cube.js / packages / cubejs-schema-compiler / compiler / CubeValidator.js View on Github external
type: Joi.any().valid('autoRollup').required(),
      maxPreAggregations: Joi.number()
    })),
    Joi.object().keys(Object.assign({}, BasePreAggregation, {
      type: Joi.any().valid('originalSql').required()
    })),
    Joi.object().keys(Object.assign({}, BasePreAggregation, {
      type: Joi.any().valid('rollup').required(),
      measureReferences: Joi.func(),
      dimensionReferences: Joi.func(),
      segmentReferences: Joi.func()
    })),
    Joi.object().keys(Object.assign({}, BasePreAggregation, {
      type: Joi.any().valid('rollup').required(),
      measureReferences: Joi.func(),
      dimensionReferences: Joi.func(),
      segmentReferences: Joi.func(),
      timeDimensionReference: Joi.func().required(),
      granularity: Joi.any().valid(
        'second', 'minute', 'hour', 'day', 'week', 'month', 'year'
      ).required()
    }))
  ))
});

class CubeValidator {
  constructor(cubeSymbols) {
    this.cubeSymbols = cubeSymbols;
    this.validCubes = {};
  }

  compile(cubes, errorReporter) {
github react-native-community / cli / packages / cli / src / tools / config / schema.ts View on Github external
import {SchemaLike} from '@hapi/joi';

const map = (key: RegExp | SchemaLike, value: SchemaLike) =>
  t
    .object()
    .unknown(true)
    .pattern(key, value);

/**
 * Schema for CommandT
 */
const command = t.object({
  name: t.string().required(),
  description: t.string(),
  usage: t.string(),
  func: t.func().required(),
  options: t.array().items(
    t
      .object({
        name: t.string().required(),
        description: t.string(),
        parse: t.func(),
        default: t
          .alternatives()
          .try([t.bool(), t.number(), t.string().allow(''), t.func()]),
      })
      .rename('command', 'name', {ignoreUndefined: true}),
  ),
  examples: t.array().items(
    t.object({
      desc: t.string().required(),
      cmd: t.string().required(),
github tristanls / dynamodb-lock-client / schema / failOpenConfig.js View on Github external
"use strict";

const Joi = require("@hapi/joi");

const schema = Joi.object().keys(
    {
        owner: Joi.string(),
        dynamodb: Joi.object().keys(
            {
                delete: Joi.func().required(),
                get: Joi.func().required(),
                put: Joi.func().required()
            }
        ).unknown().required(),
        lockTable: Joi.string().required(),
        partitionKey: Joi.string().invalid("fencingToken", "leaseDurationMs", "owner", "guid").required(),
        heartbeatPeriodMs: Joi.number().integer().min(0),
        leaseDurationMs: Joi.number().integer().min(0).required(),
        trustLocalTime: Joi.boolean(),
        retryCount: Joi.number().integer().min(0)
    }
).required();

module.exports = schema;
github hydra-newmedia / hapi-sentry / schema.js View on Github external
'use strict';

const { Severity } = require('@sentry/node');
const joi = require('@hapi/joi');

const levels = Object.values(Severity).filter(level => typeof level === 'string')
  || ['fatal', 'error', 'warning', 'log', 'info', 'debug', 'critical'];

const sentryClient = joi.object().keys({
  configureScope: joi.func().minArity(1),
  Scope: joi.func().required(),
  Handlers: joi.object().keys({
    parseRequest: joi.func().minArity(2).required(),
  }).unknown().required(),
  withScope: joi.func().minArity(1).required(),
  captureException: joi.func().minArity(1).required(),
}).unknown();

const sentryOptions = joi.object().keys({
  dsn: joi.string().uri().allow(false).required(),
}).unknown();

module.exports = joi.object().keys({
  baseUri: joi.string().uri(),
  trackUser: joi.boolean().default(true),
  scope: joi.object().keys({
    tags: joi.array().items(joi.object().keys({
      name: joi.string().required(),
      value: joi.any().required(),
    })),
    level: joi.string().only(levels),
github futurestudio / hapi-pulse / lib / options-schema.js View on Github external
'use strict'

const Joi = require('@hapi/joi')

module.exports = Joi.object({
  signals: Joi.alternatives(
    Joi.array().items(
      Joi.string().description('Shutdown signal')
    ).min(1).description('Shutdown signals to listen on for gracefully stop the hapi server'),
    Joi.string().description('Shutdown signal')
  ),
  logger: Joi.object(),
  preServerStop: Joi.func(),
  postServerStop: Joi.func(),
  preShutdown: Joi.func()
}).unknown(true)