How to use the joi.bool 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 samhagman / flough / src / flow / public_methods / static / search.js View on Github external
return new Promise((resolve, reject) => {

        const searchSchema = Joi.object().keys({
            jobId:       Joi.array().items(Joi.number()).single(),
            UUID:        Joi.array().items(Joi.string()).single(),
            type:        Joi.array().items(Joi.string()).single(),
            isCompleted: Joi.bool(),
            isCancelled: Joi.bool(),
            kueActive:   Joi.bool()
        });

        const validResult = Joi.validate([ ...arguments ][ 1 ], searchSchema, { abortEarly: false, convert: true });

        if (validResult.error) {
            Logger.error('Error with Flow.search: \n' + validResult.error);
            return reject(new Error('Invalid search parameters for Flow.search'));
        }

        // MongoDB Search Object
        let searchOptions = {};

        if (isCompleted !== undefined) {
            searchOptions.isCompleted = isCompleted;
github NervJS / taro / packages / taro-cli / src / doctor / configSchema.ts View on Github external
// https://webpack.js.org/configuration/entry-context/#entry
    'entry': Joi.alternatives(
      Joi.string(),
      Joi.array().items(Joi.alternatives(
        Joi.string(),
        Joi.object().pattern(
          Joi.string(),
          Joi.alternatives(
            Joi.string(),
            Joi.array().items(Joi.string())
          )
        )
      )),
      Joi.func()
    ),
    'enableSourceMap': Joi.bool(),
    'enableExtract': Joi.bool(),
    'cssLoaderOption': Joi.object(), // 第三方配置
    'styleLoaderOption': Joi.object(), // 第三方配置
    'sassLoaderOption': Joi.object(), // 第三方配置
    'lessLoaderOption': Joi.object(), // 第三方配置
    'stylusLoaderOption': Joi.object(), // 第三方配置
    'mediaUrlLoaderOption': Joi.object(), // 第三方配置
    'fontUrlLoaderOption': Joi.object(), // 第三方配置
    'imageUrlLoaderOption': Joi.object(), // 第三方配置
    'miniCssExtractPluginOption': Joi.object(), // 第三方配置

    'module': Joi.object().keys({
      'postcss': Joi.object().pattern(
        Joi.string(),
        Joi.object().keys({
          'enable': Joi.bool(),
github freeCodeCamp / freeCodeCamp / curriculum / schema / challengeSchema.js View on Github external
Joi.array().items(Joi.string().allow('')),
          Joi.string().allow('')
        ]
      })
    ),
    guideUrl: Joi.string().uri({ scheme: 'https' }),
    videoUrl: Joi.string().allow(''),
    forumTopicId: Joi.number(),
    helpRoom: Joi.string(),
    id: Joi.objectId().required(),
    instructions: Joi.string().allow(''),
    isBeta: Joi.bool(),
    isComingSoon: Joi.bool(),
    isLocked: Joi.bool(),
    isPrivate: Joi.bool(),
    isRequired: Joi.bool(),
    name: Joi.string(),
    order: Joi.number(),
    required: Joi.array().items(
      Joi.object().keys({
        link: Joi.string(),
        raw: Joi.bool(),
        src: Joi.string(),
        crossDomain: Joi.bool()
      })
    ),
    solutions: Joi.array().items(Joi.string().optional()),
    superBlock: Joi.string(),
    superOrder: Joi.number(),
    suborder: Joi.number(),
    tests: Joi.array().items(
      // public challenges
github sqren / backport / src / lib / schemas.ts View on Github external
import Joi, { ValidationError, SchemaLike } from 'joi';
import { HandledError } from './errors';
import { GlobalConfig, ProjectConfigRaw } from '../types/types';

const branchesSchema = Joi.array().items(
  Joi.object().keys({
    name: Joi.string().required(),
    checked: Joi.bool()
  }),
  Joi.string()
);

const configOptions = {
  all: Joi.bool(),
  multiple: Joi.bool(),
  multipleCommits: Joi.bool(),
  multipleBranches: Joi.bool()
};

export const projectConfig = Joi.object().keys({
  upstream: Joi.string().required(),
  branches: branchesSchema.required(),
  labels: Joi.array().items(Joi.string()),
  ...configOptions
github elastic / kibana / x-pack / legacy / plugins / apm / server / lib / helpers / input_validation.ts View on Github external
export const withDefaultValidators = (
  validators: { [key: string]: Schema } = {}
) => {
  return Joi.object().keys({
    _debug: Joi.bool(),
    start: dateValidation,
    end: dateValidation,
    uiFilters: Joi.string(),
    ...validators
  });
};
github freeCodeCamp / freeCodeCamp / seed / schema / challengeSchema.js View on Github external
],
      tail: [
        Joi.array().items(Joi.string().allow('')),
        Joi.string().allow('')
      ],
      contents: [
        Joi.array().items(Joi.string().allow('')),
        Joi.string().allow('')
      ]
    })
  ),
  guideUrl: Joi.string().uri({ scheme: 'https' }),
  helpRoom: Joi.string(),
  id: Joi.objectId().required(),
  isBeta: Joi.bool(),
  isComingSoon: Joi.bool(),
  isLocked: Joi.bool(),
  isPrivate: Joi.bool(),
  isRequired: Joi.bool(),
  name: Joi.string(),
  order: Joi.number().options({ convert: false }),
  required: Joi.array().items(
    Joi.object().keys({
      link: Joi.string(),
      raw: Joi.bool(),
      src: Joi.string(),
      crossDomain: Joi.bool()
    })
  ),
  solutions: Joi.array().items(
    Joi.string().optional()
  ),
github RisingStack / training-microservices-v3 / product / config / db.js View on Github external
'use strict'

const path = require('path')
const joi = require('joi')

const envVarsSchema = joi.object({
  DB_HOST: joi.string().required(),
  DB_USER: joi.string().required(),
  DB_PASSWORD: joi.string().allow('').required(),
  DB_DATABASE: joi.string().required(),
  DB_PORT: joi.number().required(),
  DB_POOL_MIN: joi.number().default(1),
  DB_POOL_MAX: joi.number().default(20),
  DB_DEBUG: joi.bool().default(false)
}).unknown()
  .required()

const envVars = joi.attempt(process.env, envVarsSchema)

const config = {
  client: 'pg',
  connection: {
    host: process.env.DB_HOST,
    user: process.env.DB_USER,
    password: process.env.DB_PASSWORD,
    database: process.env.DB_DATABASE,
    port: process.env.DB_PORT
  },
  pool: {
    min: envVars.DB_POOL_MIN,
github Flood-UI / flood / server / routes / auth.js View on Github external
return res.json({
    success: true,
    token: `JWT ${token}`,
    username,
    isAdmin,
  });
};

const authValidation = joi.object().keys({
  username: joi.string(),
  password: joi.string(),
  host: joi.string(),
  port: joi.string(),
  socketPath: joi.string(),
  isAdmin: joi.bool(),
});

router.use('/', (req, res, next) => {
  const validation = joi.validate(req.body, authValidation);

  if (!validation.error) {
    next();
  } else {
    res.status(422).json({
      message: 'Validation error.',
      error: validation.error,
    });
  }
});

router.use('/users', passport.authenticate('jwt', {session: false}), requireAdmin);
github freeCodeCamp / freeCodeCamp / seed / schema / challengeSchema.js View on Github external
Joi.array().items(Joi.string().allow('')),
        Joi.string().allow('')
      ],
      contents: [
        Joi.array().items(Joi.string().allow('')),
        Joi.string().allow('')
      ]
    })
  ),
  guideUrl: Joi.string().uri({ scheme: 'https' }),
  helpRoom: Joi.string(),
  id: Joi.objectId().required(),
  isBeta: Joi.bool(),
  isComingSoon: Joi.bool(),
  isLocked: Joi.bool(),
  isPrivate: Joi.bool(),
  isRequired: Joi.bool(),
  name: Joi.string(),
  order: Joi.number().options({ convert: false }),
  required: Joi.array().items(
    Joi.object().keys({
      link: Joi.string(),
      raw: Joi.bool(),
      src: Joi.string(),
      crossDomain: Joi.bool()
    })
  ),
  solutions: Joi.array().items(
    Joi.string().optional()
  ),
  superBlock: Joi.string(),
  superOrder: Joi.number().options({ convert: false }),
github Paratii-Video / paratii-js / src / schemas.js View on Github external
joi.string().default('/dns4/star.paratii.video/tcp/443/wss/p2p-webrtc-star'),
        joi.string().default('/dns/ws.star.paratii.video/wss/p2p-websocket-star/')
    ),
  bootstrap: joi
    .array()
    .ordered(
        joi.string().default('/dns4/bootstrap.paratii.video/tcp/443/wss/ipfs/QmeUmy6UtuEs91TH6bKnfuU1Yvp63CkZJWm624MjBEBazW')
    ),
  chunkSize: joi.number().default(128 * 1024),
  xhrChunkSize: joi.number().default(1 * 1024 * 1024),
  maxFileSize: joi.number().default(4 * 1024 * 1024 * 1024),
  defaultTranscoder: joi.string().default('/dns4/bootstrap.paratii.video/tcp/443/wss/ipfs/QmeUmy6UtuEs91TH6bKnfuU1Yvp63CkZJWm624MjBEBazW'),
  remoteIPFSNode: joi.string().default('/dns4/bootstrap.paratii.video/tcp/443/wss/ipfs/QmeUmy6UtuEs91TH6bKnfuU1Yvp63CkZJWm624MjBEBazW'),
  transcoderDropUrl: joi.string().default('https://uploader.paratii.video/api/v1/transcode'),
  instance: joi.any().default(null),
  expressUploading: joi.bool().default(true)
}).default()

/**
  * @typedef {Array} dbSchema
  * @property {string} [provider=https://db.paratii.video/api/v1/] provider of the db
 */
const dbSchema = joi.object({
  provider: joi.string().default('https://db.paratii.video/api/v1/')
}).default()

 /**
  * @todo some description are still not written
  * @typedef {Array} videoSchema
  * @property {string=} id id of the video
  * @property {string=} author author of the video
  * @property {string=} ownershipProof ownership proof for the video