How to use the joi.boolean function in joi

To help you get started, we’ve selected a few 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 godaddy / timings / routes / v2 / post-routes.js View on Github external
}).length(1).required(),
    baseline: joi.object({
      days: joi.number().integer(),
      perc: joi.number().integer().max(100),
      padding: joi.number().min(1),
      src: joi.string().allow(''),
      aggField: joi.string().allow(''),
      searchUrl: joi.string().allow(''),
      incl: joi.object(),
      excl: joi.object()
    }),
    flags: joi.object({
      assertBaseline: joi.boolean(),
      assertRum: joi.boolean(),
      debug: joi.boolean(),
      esTrace: joi.boolean(),
      esCreate: joi.boolean(),
      passOnFailedAssert: joi.boolean()
    }),
    log: joi.object({
      team: joi.string(),
      browser: joi.string()
    }).pattern(/[a-zA-Z0-9]{3,}/, joi.string()).required()
  });

  // Get the required 'log' parameters from main config
  const logObj = {
    team: joi.string(),
    browser: joi.string()
  };
  const reqLogs = nconf.get('params:required');
  if (reqLogs.length > 0) {
github clarkie / dynogels / lib / schema.js View on Github external
hashKey: Joi.string().required(),
  rangeKey: Joi.string(),
  tableName: Joi.alternatives().try(Joi.string(), Joi.func()),
  indexes: Joi.array().items(internals.secondaryIndexSchema),
  schema: Joi.object(),
  timestamps: Joi.boolean().default(false),
  createdAt: Joi.alternatives().try(Joi.string(), Joi.boolean()),
  updatedAt: Joi.alternatives().try(Joi.string(), Joi.boolean()),
  log: Joi.object({
    info: Joi.func(),
    warn: Joi.func(),
  }).optional().unknown(),

  // based on Joi internals
  validation: {
    abortEarly: Joi.boolean(),
    convert: Joi.boolean(),
    allowUnknown: Joi.boolean(),
    skipFunctions: Joi.boolean(),
    stripUnknown: Joi.boolean(),
    language: Joi.object(),
    presence: Joi.string().allow('optional', 'required', 'forbidden', 'ignore'),
    strip: Joi.boolean(),
    noDefaults: Joi.boolean()
  }
}).required();

internals.wireType = (key) => {
  switch (key) {
    case 'string':
      return 'S';
    case 'date':
github plouc / nivo-api / src / mapping / radar.js View on Github external
// data
            data: Joi.array().min(1).required(),
            keys: Joi.array().sparse(false).min(1).unique().required(),
            indexBy: Joi.string().required(),

            curve: Joi.string(),

            borderWidth: Joi.number().min(0),
            borderColor: Joi.string(),

            gridLevels: Joi.number().integer().positive(),
            gridShape: Joi.any().valid(['linear', 'circular']),
            gridLabelOffset: Joi.number(),

            // labels
            enableLabels: Joi.boolean(),
            labelsTextColor: Joi.string(),
            labelsLinkColor: Joi.string(),

            // dots
            enableDots: Joi.boolean(),
            dotSize: Joi.number().min(0),
            dotColor: Joi.string(),
            dotBorderWidth: Joi.number().min(0),
            dotBorderColor: Joi.string(),
            enableDotLabel: Joi.boolean(),
            dotLabel: Joi.string(),
            dotLabelYOffset: Joi.number(),

            // theming
            colors: Joi.string(),
            colorBy: Joi.string(),
github bentonam / fakeit / test / fixtures / models / flight-data / validation / continents.model.js View on Github external
var utils = require('../../../../utils.js');
var is = require('joi');

module.exports = is.object({
  name: 'Continents',
  type: 'object',
  file: is.string(),
  root: is.string(),
  is_dependency: is.boolean(),
  dependants: is.array(),
  key: '_id',
  seed: 0,
  data: {
    min: 0,
    max: 0,
    count: 1,
    dependencies: is.array().items(is.string()).length(0),
    inputs: is.array().items(is.string()).length(1),
    pre_run: is.func(),
  },
  properties: {
    _id: utils.check('string', 'The document id', { post_build: is.func(), }),
    continent_code: utils.check('string', 'The ISO continent code', { build: is.func(), }),
    doc_type: utils.check('string', 'The document type', { value: is.string(), }),
    continent_name: utils.check('string', 'The continent name', { build: is.func(), }),
github epochtalk / epochtalk / modules / ept-threads / permissions / index.js View on Github external
}),
  title: Joi.object().keys({
    allow: Joi.boolean(),
    bypass: Joi.object().keys({
      owner: Joi.object().keys({
        admin: Joi.boolean(),
        mod: Joi.boolean()
      }).xor('admin', 'mod')
    })
  }),
  lock: Joi.object().keys({
    allow: Joi.boolean(),
    bypass: Joi.object().keys({
      owner: Joi.object().keys({
        admin: Joi.boolean(),
        mod: Joi.boolean()
      }).xor('admin', 'mod')
    })
  }),
  sticky: Joi.object().keys({
    allow: Joi.boolean(),
    bypass: Joi.object().keys({
      owner: Joi.object().keys({
        admin: Joi.boolean(),
        mod: Joi.boolean()
      }).xor('admin', 'mod')
    })
  }),
  move: Joi.object().keys({
    allow: Joi.boolean(),
    bypass: Joi.object().keys({
      owner: Joi.object().keys({
github khalyomede / php-next / src / main.ts View on Github external
const parseOptions = (options: Options): Options => {
	let parsedOptions = options;

	const schema = joi.object().keys({
		features: joi.array().items(joi.func()),
		target: joi.number().integer(),
		validate: joi.boolean(),
		debug: joi.boolean()
	});

	joi.validate(parsedOptions, schema);

	if (
		parsedOptions !== null &&
		parsedOptions !== undefined &&
		parsedOptions.constructor === Object
	) {
		if (!("target" in parsedOptions)) {
			parseOptions["target"] = "7.0.0";
		}

		if (!("debug" in parsedOptions)) {
			parsedOptions["debug"] = false;
		}
github epochtalk / epochtalk / modules / ept-posts / routes / delete.js View on Github external
* @apiError (Error 500) InternalServerError There was an issue deleting the post
  */
module.exports = {
  method: 'DELETE',
  path: '/api/posts/{id}',
  options: {
    auth: { strategy: 'jwt' },
    plugins: {
      mod_log: {
        type: 'posts.delete',
        data: { id: 'params.id' }
      }
    },
    validate: {
      params: { id: Joi.string().required() },
      query: { locked: Joi.boolean().default(false) }
    },
    pre: [
      { method: (request) => request.server.methods.auth.posts.delete(request.server, request.auth, request.params.id) },
      { method: (request) => request.server.methods.auth.posts.lock(request.server, request.auth, request.params.id, request.query) }
    ],
    handler: function(request) {
      var action = 'hidden';
      var promise = request.db.posts.delete(request)
      .tap(function() {
        if (request.query.locked) {
          action = 'hidden and locked';
          return request.db.posts.lock(request);
        }
      })
      .tap(function(post) {
        var email;
github taskcluster / mozilla-taskcluster / src / exchange.js View on Github external
routingKeys(...keys) {
    let result = Joi.validate(keys, Joi.array().required().includes(
      Joi.object().keys({
        name: Joi.string().required(),
        summary: Joi.string().trim().required(),
        constant: Joi.string(),
        multipleWords: Joi.boolean().default(false),
        required: Joi.boolean().default(true)
      })
    ));

    if (result.error) throw result.error;
    this.config.routingKey = result.value;
    return this;
  }
}
github epochtalk / epochtalk / server / routes / admin / roles / config.js View on Github external
all: Joi.boolean()
          }),
          privilegedSticky: Joi.object().keys({
            some: Joi.boolean(),
            all: Joi.boolean()
          }),
          privilegedMove: Joi.object().keys({
            some: Joi.boolean(),
            all: Joi.boolean()
          }),
          privilegedPurge: Joi.object().keys({
            some: Joi.boolean(),
            all: Joi.boolean()
          }),
          create: Joi.boolean(),
          byBoard: Joi.boolean(),
          viewed: Joi.boolean(),
          title: Joi.boolean(),
          lock: Joi.boolean(),
          sticky: Joi.boolean(),
          move: Joi.boolean(),
          purge: Joi.boolean()
        }),
        users: Joi.object().keys({
          privilegedDeactivate: Joi.object().keys({
            samePriority: Joi.boolean(),
            lowerPriority: Joi.boolean()
          }),
          privilegedReactivate: Joi.object().keys({
            samePriority: Joi.boolean(),
            lowerPriority: Joi.boolean()
          }),
github rbglass / chandelier / api / models / models.js View on Github external
bulb       : Joi.string(),
		qty_req    : Joi.number(),
		qty_hot    : Joi.number(),
		qty_cold   : Joi.number(),
		qty_assem  : Joi.number(),
		notes      : Joi.string(),
		pdf_rank   : Joi.number()
	}),

	products: Joi.object().keys({
		id         : Joi.string().strip(),
		sku        : Joi.string(),
		type       : Joi.string(),
		name       : Joi.string(),
		description: Joi.string(),
		active     : Joi.boolean(),
		saleable   : Joi.boolean()
	})
};