How to use the @hapi/joi.array 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 HelpAssistHer / help-assist-her / server / locations / schema / joi-schema.js View on Github external
'use strict'

const Joi = require('@hapi/joi')
const isObjectId = require('../../util/is-object-id')

const pointSchemaJoi = Joi.object().keys({
	_id: Joi.any()
	type: Joi.string()
	coordinates: Joi.array()
				.required(), // general continental US longitude parameters
				.required(), // general continental US latitude parameters, to keep
			// from accidentally switching lat, lng

const addressSchemaJoi = Joi.object().keys({
github badges / shields / services / hexpm / hexpm.service.js View on Github external
const hexSchema = Joi.object({
  downloads: Joi.object({
    // these keys may or may not exist
    all: Joi.number()
    week: Joi.number()
    day: Joi.number()
  meta: Joi.object({
    licenses: Joi.array().required(),
  releases: Joi.array()
    .items(Joi.object({ version: Joi.string().required() }).required())

class BaseHexPmService extends BaseJsonService {
  static get defaultBadgeData() {
    return { label: 'hex' }

  async fetch({ packageName }) {
    return this._requestJson({
      schema: hexSchema,
      url: `${packageName}`,
github GoogleChrome / workbox / packages / workbox-build / src / entry-points / options / get-manifest-schema.js View on Github external
Use of this source code is governed by an MIT-style
  license that can be found in the LICENSE file or at

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

const baseSchema = require('./base-schema');
const defaults = require('./defaults');

// Define some additional constraints.
module.exports = baseSchema.keys({
  globDirectory: joi.string().required(),
  globFollow: joi.boolean().default(defaults.globFollow),
  globIgnores: joi.array().items(joi.string()).default(defaults.globIgnores),
  globPatterns: joi.array().items(joi.string()).default(defaults.globPatterns),
  globStrict: joi.boolean().default(defaults.globStrict),
github cube-js / cube.js / packages / cubejs-api-gateway / index.js View on Github external
filters: Joi.array().items(Joi.object().keys({
    dimension: id,
    member: id,
    operator: Joi.valid(operators).required(),
    values: Joi.array().items(Joi.string().allow(''))
  }).xor('dimension', 'member')),
  timeDimensions: Joi.array().items(Joi.object().keys({
    dimension: id.required(),
    granularity: Joi.valid('day', 'month', 'year', 'week', 'hour', 'minute', 'second', null),
    dateRange: [
  order: Joi.object().pattern(id, Joi.valid('asc', 'desc')),
  segments: Joi.array().items(id),
  timezone: Joi.string(),
  limit: Joi.number().integer().min(1).max(50000),
  offset: Joi.number().integer().min(0),
  renewQuery: Joi.boolean(),
  ungrouped: Joi.boolean()

const normalizeQuery = (query) => {
  // eslint-disable-next-line no-unused-vars
  const { error, value } = Joi.validate(query, querySchema);
  if (error) {
    throw new UserError(`Invalid query format: ${error.message || error.toString()}`);
  const validQuery = query.measures && query.measures.length ||
    query.dimensions && query.dimensions.length ||
    query.timeDimensions && query.timeDimensions.filter(td => !!td.granularity).length;
github Unleash / unleash / lib / state-service.js View on Github external
const strategySchema = require('./routes/admin-api/strategy-schema');
const YAML = require('js-yaml');
const {
} = require('./event-type');

const dataSchema = joi.object().keys({
    version: joi.number(),
    features: joi
    strategies: joi

function readFile(file) {
    return new Promise((resolve, reject) =>
        fs.readFile(file, (err, v) => (err ? reject(err) : resolve(v)))

function parseFile(file, data) {
    return mime.getType(file) === 'text/yaml'
        ? YAML.safeLoad(data)
        : JSON.parse(data);
github brave-intl / bat-ledger / ledger / controllers / registrar.js View on Github external
tags: ['api'],

  validate: {
    params: Joi.object().keys({
      uId: Joi.string().hex().length(31).required().description('the universally-unique identifier'),
      apiV: Joi.string().required().description('the api version')
    payload: Joi.object().keys({
      proof: Joi.string().required().description('credential registration request')

  response: {
    schema: Joi.object().keys({
      verification: Joi.string().required().description('credential registration response'),
      surveyorIds: Joi.array().min(1).items(Joi.string()).required().description('allowed surveyors')

const keychainSchema = Joi.object().keys({
  xpub: braveJoi.string().Xpub().required(),
  path: Joi.string().optional(),
  encryptedXprv: Joi.string().optional()

v1.createPersona =
{ handler: (runtime) => createPersona(runtime, 1),
  description: 'Registers a user persona',
  tags: ['api'],

  validate: {
github glennjones / hapi-swagger / examples / assets / routes-simple.js View on Github external
  created: Joi.string()
    .description('ISO date string')
  modified: Joi.string()
    .description('ISO date string')
  .description('json body for sum');

const listModel = Joi.object({
  items: Joi.array().items(sumModel),
  count: Joi.number()
  pageSize: Joi.number()
  page: Joi.number()
  pageCount: Joi.number()

const resultModel = Joi.object({
  equals: Joi.number()
github felixheck / laabr / src / validator.js View on Github external
indent: joi.alternatives().try(joi.number(), joi.string()).allow('').default(2),
    preformatter: joi.function().maxArity(2),
    postformatter: joi.function().maxArity(2),
    handleUncaught: joi.boolean().default(false),
    stream: joi.object().allow(null),
    hapiPino: joi.object({
      stream: joi.object().allow(null),
      prettyPrint: joi.boolean(),
      tags: joi.object(),
      allTags: joi.string(),
      instance: joi.object(),
      logEvents: joi.alternatives().try(joi.array().items(joi.string()), joi.any().allow(false, null)),
      mergeHapiLogData: joi.boolean().default(false),
      serializers: joi.object(),
      logRouteTags: joi.boolean(),
      ignorePaths: joi.array().items(joi.string()),
      logPayload: joi.boolean().default(true),
      level: joi.string()
    pino: joi.object({
      safe: joi.boolean(),
      name: joi.string(),
      serializers: joi.object(),
      timestamp: joi.alternatives().try(joi.function(), joi.boolean()),
      slowtime: joi.boolean(),
      extreme: joi.boolean(),
      level: joi.string(),
      levelVal: joi.number(),
      customLevels: joi.object(),
      redact: joi.alternatives().try(joi.array(), joi.object()),
      prettyPrint: joi.any(),
      messageKey: joi.string().default('msg'),
github openmobilityfoundation / mds-core / packages / mds-compliance / validators.ts View on Github external
rule_id: Joi.string()
  rule_type: Joi.string()
    .valid(['count', 'time', 'speed', 'user'])
  rule_units: Joi.string().valid(['seconds', 'minutes', 'hours', 'mph', 'kph']),
  geographies: Joi.array().items(Joi.string().guid()),
  statuses: Joi.object().keys({
    available: Joi.array(),
    reserved: Joi.array(),
    unavailable: Joi.array(),
    removed: Joi.array(),
    inactive: Joi.array(),
    trip: Joi.array(),
    elsewhere: Joi.array()
  vehicle_types: Joi.array().items(Joi.string().valid(Object.values(VEHICLE_TYPES))),
  maximum: Joi.number(),
  minimum: Joi.number(),
  start_time: Joi.string(),
  end_time: Joi.string(),
  days: Joi.array().items(Joi.string().valid(DAYS_OF_WEEK)),
  messages: Joi.object(),
  value_url: Joi.string().uri()

const policiesSchema = Joi.array().items(
    name: Joi.string().required(),
    description: Joi.string().required(),
    policy_id: Joi.string()
github badges / shields / services / ubuntu / ubuntu.service.js View on Github external
'use strict'

const Joi = require('@hapi/joi')
const { renderVersionBadge } = require('../version')
const { BaseJsonService, NotFound } = require('..')

const schema = Joi.object({
  entries: Joi.array()
        source_package_version: Joi.string().required(),

module.exports = class Ubuntu extends BaseJsonService {
  static get category() {
    return 'version'

  static get route() {
    return {
      base: 'ubuntu/v',