How to use the @hapi/joi.bool 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 ExpediaGroup / service-client / lib / schema.js View on Github external
const requestSchema = Joi.object({
  context: Joi.object().description('Usually the hapi `request`'),
  hostPrefix: Joi.string(),
  path: Joi.string().default(requestDefaults.path),
  method: Joi.string().required(),
  operation: Joi.string().required().description('Ex: GET_supply_properties_v1'),
  queryParams: Joi.object(),
  pathParams: Joi.object(),
  headers: Joi.object().default(requestDefaults.headers),
  payload: Joi.any(),
  redirects: Joi.alternatives().try(Joi.number(), Joi.valid(false)), // default value provided by global config
  connectTimeout: Joi.number(), // default value provided by global config
  maxConnectRetry: Joi.number(), // default value provided by global config
  timeout: Joi.number(), // default value provided by global config
  agent: Joi.object(), // default value provided by global config
  read: Joi.bool().default(requestDefaults.read),
  readOptions: Joi.object({
    timeout: Joi.number().default(requestDefaults.readOptions.timeout),
    json: Joi.valid(true, false, 'strict', 'force').default(requestDefaults.readOptions.json),
    maxBytes: Joi.number(),
    gunzip: Joi.valid(true, false, 'force').default(requestDefaults.readOptions.gunzip)
  }).default(requestDefaults.readOptions),
  plugins: Joi.object().default(requestDefaults.plugins)
}).unknown(true).default(requestDefaults)

// defaults listed in config.js
const globalSchema = Joi.object({
  plugins: Joi.array().items(Joi.function()),
  base: Joi.object(),
  overrides: Joi.object().pattern(/.+/, Joi.object())
})
github totallymoney / serverless-sns-to-sqs-events / src / schema.js View on Github external
.min(60)
		.max(1209600)
});

const sqs = Joi.alternatives().try(
	arn,
	sqsQueue.keys({
		dlq: sqsQueue.keys({
			maxReceiveCount: Joi.number().min(1)
		})
	})
);

const schema = Joi.object({
	sns: sns.required(),
	rawMessageDelivery: Joi.bool(),
	filterPolicy: Joi.object(),
	sqs: sqs.required(),
	batchSize: Joi.number()
		.min(1)
		.max(10)
});

module.exports = schema;
github ArkEcosystem / core / packages / core-api / src / handlers / wallets / schema.ts View on Github external
.alphanum()
                .length(34),
            recipientId: Joi.string()
                .alphanum()
                .length(34),
            timestamp: Joi.number()
                .integer()
                .min(0),
            amount: Joi.number()
                .integer()
                .min(0),
            fee: Joi.number()
                .integer()
                .min(0),
            vendorFieldHex: Joi.string().hex(),
            transform: Joi.bool().default(true),
        },
    },
};

export const transactionsSent: object = {
    params: {
        id: Joi.string(),
    },
    query: {
        ...pagination,
        ...{
            orderBy: Joi.string(),
            id: Joi.string()
                .hex()
                .length(64),
            blockId,
github ArkEcosystem / core / packages / core-api / src / handlers / locks / schema.ts View on Github external
.integer()
                .min(0),
        }),
        vendorField: Joi.string()
            .min(1)
            .max(255),
        expirationType: Joi.number().only(...Object.values(Enums.HtlcLockExpirationType)),
        expirationValue: Joi.object().keys({
            from: Joi.number()
                .integer()
                .min(0),
            to: Joi.number()
                .integer()
                .min(0),
        }),
        isExpired: Joi.bool(),
    },
};

export const unlocked: object = {
    query: {
        ...pagination,
        ...{
            orderBy: orderBy(transactionIteratees),
        },
    },
    payload: {
        ids: Joi.array()
            .unique()
            .min(1)
            .max(25)
            .items(
github ArkEcosystem / core / packages / core-api / src / handlers / bridgechains / schema.ts View on Github external
},
    },
    payload: {
        address,
        publicKey,
        bridgechainRepository: Joi.string().max(80),
        genesisHash: Joi.string()
            .hex()
            .length(64),
        name: genericName,
        seedNodes: Joi.array()
            .unique()
            .min(1)
            .max(10)
            .items(Joi.string().ip()),
        isResigned: Joi.bool(),
    },
};
github JKHeadley / rest-hapi / utilities / rest-helper-factory.js View on Github external
if (model.routeOptions) {
        resourceAliasForRoute = model.routeOptions.alias || model.modelName
      } else {
        resourceAliasForRoute = model.modelName
      }

      let handler = HandlerHelper.generateDeleteHandler(model, options, Log)

      let payloadModel = null
      if (config.enableSoftDelete) {
        payloadModel = Joi.alternatives().try(
          Joi.array().items(
            Joi.object({
              _id: Joi.objectId(),
              hardDelete: Joi.bool().default(false)
            })
          ),
          Joi.array().items(Joi.objectId())
        )
      } else {
        payloadModel = Joi.array().items(Joi.objectId())
      }

      if (!config.enablePayloadValidation) {
        payloadModel = Joi.alternatives().try(payloadModel, Joi.any())
      }

      let auth = false
      let deleteManyHeadersValidation = Object.assign(headersValidation, {})

      if (config.authStrategy && model.routeOptions.deleteAuth !== false) {
github ArkEcosystem / core / packages / core-api / src / handlers / businesses / schema.ts View on Github external
...pagination,
        ...{
            orderBy: orderBy(businessIteratees),
        },
    },
    payload: {
        address,
        publicKey,
        name: genericName,
        website: Joi.string().max(80),
        vat: Joi.string()
            .alphanum()
            .max(15),
        repository: Joi.string().max(80),
        isResigned: Joi.bool(),
        transform: Joi.bool().default(true),
    },
};
github ArkEcosystem / core / packages / core-api / src / handlers / transactions / schema.ts View on Github external
export const show: object = {
    params: {
        id: Joi.string()
            .hex()
            .length(64),
    },
    query: {
        transform: Joi.bool().default(true),
    },
};

export const unconfirmed: object = {
    query: {
        ...pagination,
        ...{
            transform: Joi.bool().default(true),
        },
    },
};

export const showUnconfirmed: object = {
    params: {
        id: Joi.string()
            .hex()
            .length(64),
    },
};

export const search: object = {
    query: {
        ...pagination,
        ...{
github JKHeadley / rest-hapi / utilities / joi-mongoose-helper.js View on Github external
if (!fieldCopy.type) {
    fieldCopy.type = {
      schemaName: 'None'
    }
  }

  switch (fieldCopy.type.schemaName) {
    case 'ObjectId':
      model = internals.joiObjectId()
      break
    case 'Mixed':
      model = Joi.object()
      break
    case 'Boolean':
      model = Joi.bool()
      break
    case 'Number':
      model = Joi.number()
      break
    case 'Date':
      model = Joi.date()
      break
    case 'String':
      if (fieldCopy.enum) {
        model = Joi.any().only(fieldCopy.enum)
      } else if (fieldCopy.regex) {
        if (!(fieldCopy.regex instanceof RegExp)) {
          if (fieldCopy.regex.options) {
            model = Joi.string().regex(
              fieldCopy.regex.pattern,
              fieldCopy.regex.options
github badges / shields / core / base-service / redirector.js View on Github external
const trace = require('./trace')

const attrSchema = Joi.object({
  name: Joi.string().min(3),
  category: isValidCategory,
  route: isValidRoute,
  transformPath: Joi.func()
    .maxArity(1)
    .required()
    .error(
      () =>
        '"transformPath" must be a function that transforms named params to a new path'
    ),
  transformQueryParams: Joi.func().arity(1),
  dateAdded: Joi.date().required(),
  overrideTransformedQueryParams: Joi.bool().optional(),
}).required()

module.exports = function redirector(attrs) {
  const {
    name,
    category,
    route,
    transformPath,
    transformQueryParams,
    overrideTransformedQueryParams,
  } = Joi.attempt(attrs, attrSchema, `Redirector for ${attrs.route.base}`)

  return class Redirector extends BaseService {
    static get name() {
      if (name) {
        return name