How to use the @hapi/joi.boolean 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 alexandercerutti / passkit-generator / src / schema.ts View on Github external
numberStyle?: string;
}

const field = Joi.object().keys({
	attributedValue: Joi.alternatives(Joi.string().allow(""), Joi.number(), Joi.date().iso()),
	changeMessage: Joi.string(),
	dataDetectorType: Joi.array().items(Joi.string().regex(/(PKDataDetectorTypePhoneNumber|PKDataDetectorTypeLink|PKDataDetectorTypeAddress|PKDataDetectorTypeCalendarEvent)/, "dataDetectorType")),
	label: Joi.string().allow(""),
	textAlignment: Joi.string().regex(/(PKTextAlignmentLeft|PKTextAlignmentCenter|PKTextAlignmentRight|PKTextAlignmentNatural)/, "graphic-alignment"),
	key: Joi.string().required(),
	value: Joi.alternatives(Joi.string().allow(""), Joi.number(), Joi.date().iso()).required(),
	semantics,
	// date fields formatters, all optionals
	dateStyle: Joi.string().regex(/(PKDateStyleNone|PKDateStyleShort|PKDateStyleMedium|PKDateStyleLong|PKDateStyleFull)/, "date style"),
	ignoreTimeZone: Joi.boolean(),
	isRelative: Joi.boolean(),
	timeStyle: Joi.string().regex(/(PKDateStyleNone|PKDateStyleShort|PKDateStyleMedium|PKDateStyleLong|PKDateStyleFull)/, "date style"),
	// number fields formatters, all optionals
	currencyCode: Joi.string()
		.when("value", {
			is: Joi.number(),
			otherwise: Joi.string().forbidden()
		}),
	numberStyle: Joi.string()
		.regex(/(PKNumberStyleDecimal|PKNumberStylePercent|PKNumberStyleScientific|PKNumberStyleSpellOut)/)
		.when("value", {
			is: Joi.number(),
			otherwise: Joi.string().forbidden()
		}),
});

export interface Beacon {
github pa11y / pa11y-webservice / route / task.js View on Github external
if (!task) {
				return reply.response('Not Found').code(404);
			}

			const results = await model.result.getByTaskId(request.params.id, request.query);
			if (!results) {
				return reply.response('No results found for task').code(500);
			}
			return reply.response(results).code(200);
		},
		options: {
			validate: {
				query: Joi.object({
					from: Joi.string().isoDate(),
					to: Joi.string().isoDate(),
					full: Joi.boolean()
				}),
				payload: false
			}
		}
	});

	// Get a result for a task
	server.route({
		method: 'GET',
		path: '/tasks/{tid}/results/{rid}',
		handler: async (request, reply) => {
			const rid = request.params.rid;
			const tid = request.params.tid;
			const result = await model.result.getByIdAndTaskId(rid, tid, request.query);

			if (!result) {
github openmobilityfoundation / mds-core / packages / mds-compliance / validators.ts View on Github external
.required(),
    features: Joi.array()
      .min(1)
      .items(featureSchema)
      .required()
  })
  .unknown(true) // TODO

const geographiesSchema = Joi.array().items(
  Joi.object()
    .keys({
      geography_id: Joi.string()
        .guid()
        .required(),
      geography_json: featureCollectionSchema,
      read_only: Joi.boolean().allow(null),
      previous_geography_ids: Joi.array()
        .items(Joi.string().guid())
        .allow(null),
      name: Joi.string().required()
    })
    .unknown(true)
)

const eventsSchema = Joi.array().items(
  Joi.object().keys({
    device_id: Joi.string()
      .guid()
      .required(),
    provider_id: Joi.string()
      .guid()
      .required(),
github danielb2 / blipp / lib / index.js View on Github external
'use strict';

// Load modules
const Chalk = require('chalk');
const Hoek = require('@hapi/hoek');
const Joi = require('@hapi/joi');
const Pkg = require('../package.json');
const Table = require('easy-table');


// Declare internals
const internals = {
    schema: {
        showAuth: Joi.boolean().default(false),
        showScope: Joi.boolean().default(false),
        showStart: Joi.boolean().default(true)
    }
};

exports.register = function (server, options) {

    const result = Joi.validate(options, internals.schema);
    Hoek.assert(!result.error, result.error && result.error.annotate());
    options = result.value;

    server.expose('text', function () {

        const info = this.info();
        return internals.printableInfo(info, options);
    });
github inaturalist / iNaturalistAPI / openapi / schema / response / taxon.js View on Github external
atlas_id: Joi.number( ).integer( ).valid( null ),
  children: Joi.array( ).items(
    Joi.object( ).meta( { className: "Taxon" } )
  ),
  complete_rank: Joi.string( ),
  complete_species_count: Joi.number( ).integer( ).valid( null ),
  conservation_status: conservationStatus,
  conservation_statuses: Joi.array( ).items(
    conservationStatus
  ),
  created_at: Joi.string( ),
  current_synonymous_taxon_ids: Joi.array( ).items(
    Joi.number( ).integer( )
  ).valid( null ),
  default_photo: photo,
  endemic: Joi.boolean( ),
  extinct: Joi.boolean( ),
  flag_counts: Joi.object( ).keys( {
    resolved: Joi.number( ).integer( ),
    unresolved: Joi.number( ).integer( )
  } ).unknown( false ),
  iconic_taxon_id: Joi.number( ).integer( ).valid( null ),
  iconic_taxon_name: Joi.string( ),
  introduced: Joi.boolean( ),
  is_active: Joi.boolean( ),
  listed_taxa: Joi.array( ).items(
    Joi.object( ).keys( {
      id: Joi.number( ).integer( ),
      establishment_means: Joi.string( ),
      list,
      taxon: Joi.object( ).meta( { className: "Taxon" } ),
      taxon_id: Joi.number( ).integer( ),
github hapijs / inert / lib / directory.js View on Github external
const Joi = require('@hapi/joi');

const File = require('./file');
const Fs = require('./fs');


const internals = {};


internals.schema = Joi.object({
    path: Joi.alternatives(Joi.array().items(Joi.string()).single(), Joi.func()).required(),
    index: Joi.alternatives(Joi.boolean(), Joi.array().items(Joi.string()).single()).default(true),
    listing: Joi.boolean(),
    showHidden: Joi.boolean(),
    redirectToSlash: Joi.boolean(),
    lookupCompressed: Joi.boolean(),
    lookupMap: Joi.object().min(1).pattern(/.+/, Joi.string()),
    etagMethod: Joi.string().valid('hash', 'simple').allow(false),
    defaultExtension: Joi.string().alphanum()
});


internals.resolvePathOption = function (result) {

    if (result instanceof Error) {
        throw result;
    }

    if (typeof result === 'string') {
        return [result];
    }
github cube-js / cube.js / packages / cubejs-schema-compiler / compiler / DashboardTemplateEvaluator.js View on Github external
filters: Joi.array().items(Joi.object().keys({
    member: Joi.func().required(),
    operator: Joi.any().valid('contains', 'notContains', 'equals', 'set', 'notSet', 'gt', 'gte', 'lt', 'lte'),
    params: Joi.array().items(Joi.string().allow('').optional())
  })),
  timeDimension: Joi.object().keys({
    dimension: Joi.func().required(),
    dateRange: Joi.string().required(),
    granularity: Joi.any().valid('hour', 'day', 'week', 'month', 'year', null)
  }),
  visualization: Joi.object().keys({
    type: Joi.any().valid('bar', 'line', 'table', 'area', 'singleValue', 'pie').required(),
    autoScale: Joi.boolean(),
    showTotal: Joi.boolean(),
    y2Axis: Joi.boolean(),
    showLegend: Joi.boolean(),
    axisRotated: Joi.boolean(),
    showYLabel: Joi.boolean(),
    showY2Label: Joi.boolean(),
    showTrendline: Joi.boolean(),
    trendlineType: Joi.any().valid('linear', 'rolling'),
    trendlinePeriod: Joi.number(),
    showComparison: Joi.boolean(),
    showRowNumbers: Joi.boolean(),
    showBarChartSteps: Joi.boolean(),
    seriesPositioning: Joi.any().valid('stacked', 'grouped', 'proportional')
  }),
  pivot: Joi.object().keys({
    x: Joi.array(),
    y: Joi.array()
  }),
  layout: Joi.object().keys({
github brave-intl / bat-ledger / eyeshade / controllers / accounts.js View on Github external
return body
  },

  auth: {
    strategy: 'simple-scoped-token',
    scope: ['publishers'],
    mode: 'required'
  },

  description: 'Used by publishers for retrieving a list of balances e.g. for an owner and their channels',

  tags: [ 'api', 'publishers' ],

  validate: {
    query: Joi.object().keys({
      pending: Joi.boolean().default(false).description('whether or not a query should be done for outstanding votes'),
      account: Joi.alternatives().try(
        Joi.string().description('account (channel or owner)'),
        Joi.array().items(Joi.string().required().description('account (channel or owner)'))
      ).required()
    }).unknown(true)
  },

  response: {
    schema: Joi.array().items(
      Joi.object().keys({
        account_id: Joi.string(),
        account_type: stringValidator.valid.apply(stringValidator, accountTypes),
        balance: joiBAT.description('balance in BAT')
      })
    )
  }
github kanongil / nipo / lib / index.js View on Github external
name: Joi.string(),
        level: Joi.alternatives().try(
            Joi.number().integer().min(0).allow(Infinity),
            Joi.string().equal(...Object.keys(internals.pinoLevels.values), 'silent')
        ),
        redact: Joi.alternatives().try(
            Joi.array().items(Joi.string()).single(),
            Joi.object({
                paths: Joi.array().items(Joi.string()).single(),
                censor: Joi.alternatives().try(Joi.string(), Joi.func()),
                remove: Joi.boolean()
            })
        ),
        enabled: Joi.boolean().default(true),
        crlf: Joi.boolean(),
        timestamp: Joi.alternatives().try(Joi.boolean(), Joi.func()).default(true),
        messageKey: Joi.string(),
        //$lab:coverage:off$
        prettyPrint: internals.hasPretty ? Joi.boolean() : Joi.boolean().equal(false),
        //$lab:coverage:on$
        useLevelLabels: Joi.boolean(),
        changeLevelName: Joi.string()
    }).default({})
}).strict();


internals.onLevelChange = function (server, lvl, val, prevLvl, prevVal) {

    const levelChanged = (ref) => {

        const refVal = this.levels.values[ref];
        const isActive = refVal >= val;
github hapijs / hapi / lib / config.js View on Github external
failAction: internals.failAction,
        modify: Joi.boolean(),
        options: Joi.object(),
        ranges: Joi.boolean().default(true),
        sample: Joi.number().min(0).max(100).when('modify', { then: Joi.forbidden() }),
        schema: Joi.alternatives(Joi.object(), Joi.array(), Joi.function()).allow(true, false),
        status: Joi.object().pattern(/\d\d\d/, Joi.alternatives(Joi.object(), Joi.array(), Joi.function()).allow(true, false))
    })
        .default(),
    security: Joi.object({
        hsts: Joi.alternatives([
            Joi.object({
                maxAge: Joi.number(),
                includeSubdomains: Joi.boolean(),
                includeSubDomains: Joi.boolean(),
                preload: Joi.boolean()
            }),
            Joi.boolean(),
            Joi.number()
        ])
            .default(15768000),
        xframe: Joi.alternatives([
            Joi.boolean(),
            Joi.valid('sameorigin', 'deny'),
            Joi.object({
                rule: Joi.valid('sameorigin', 'deny', 'allow-from'),
                source: Joi.string()
            })
        ])
            .default('deny'),
        xss: Joi.boolean().default(true),
        noOpen: Joi.boolean().default(true),