当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript joi.array函数代码示例

本文整理汇总了TypeScript中joi.array函数的典型用法代码示例。如果您正苦于以下问题:TypeScript array函数的具体用法?TypeScript array怎么用?TypeScript array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了array函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1:

import * as Joi from 'joi'
import { PluginRegister } from '../../../hapi.types'
import addTeamMembers from './add-team-members'
import deleteTeamMembers from './delete-team-members'
import getTeamMembers from './get-team-members'

const multipleMembersSchema = Joi.object().keys({
  data: Joi.array().items(
    Joi.object().keys({
      id: Joi.string(),
      type: Joi.only('users'),
    }),
  ),
})

const register: PluginRegister = (server, _, next) => {

  server.route([
    {
      method: 'POST',
      path: '/teams/{teamId}/members',
      handler: {
        async: addTeamMembers,
      },
      config: {
        auth: 'attendee',
        validate: {
          params: {
            teamId: Joi.string(),
          },
          payload: multipleMembersSchema,
开发者ID:TechNottingham,项目名称:Hack24-API,代码行数:31,代码来源:index.ts

示例2:

export let label = Joi.object({
	name: Joi.string().regex(regex.nameUTF).required(),
	version: Joi.string().allow(null).regex(regex.semverC).description('semver').optional()
}).description('label');

export let project = Joi.object({
	url: Joi.string().regex(regex.uri).required()
}).description('project');

export let person = Joi.object({
	name: Joi.string().regex(regex.nameUTF).required(),
	url: Joi.string().allow(null).regex(regex.uri).optional().default(null)
}).description('person');

export let repository = Joi.object({
	// use default?
	url: Joi.string().regex(regex.uri).required()
}).description('repository');

export let header = Joi.object({
	label: label.required(),
	project: Joi.array().min(1).items(project).required(),
	repository: repository.required(),
	authors: Joi.array().min(1).items(person).required()
}).description('definition-header').options({
	allowUnknown: true,
	stripUnknown: true,
	convert: false
});
开发者ID:DefinitelyTyped,项目名称:definition-header,代码行数:29,代码来源:schema.ts

示例3:

  // NOTE: 考虑是否增加第三方模块的配置检查
  'plugins': Joi.object().pattern(
    Joi.string(), Joi.object()
  ),

  'env': Joi.object().pattern(
    Joi.string(), Joi.string()
  ),

  'defineConstants': Joi.object().pattern(
    Joi.string(), Joi.string()
  ),

  'copy': Joi.object().keys({
    'patterns': Joi.array().items(Joi.object().keys({
      'from': Joi.string().required(),
      'to': Joi.string().required(),
      'ignore': Joi.string()
    })),

    'options': Joi.object().keys({
      'ignore': Joi.array().items(Joi.string())
    })
  }),

  'weapp': Joi.object().keys({
    'compile': Joi.object().keys({
      'exclude': Joi.array().items(Joi.string())
    }),
    'module': Joi.object() // 第三方配置
开发者ID:YangShaoQun,项目名称:taro,代码行数:30,代码来源:configSchema.ts

示例4:

export const BotEditSchema = Joi.object().keys({
  name: Joi.string()
    .allow('')
    .max(50),
  // tslint:disable-next-line:no-null-keyword
  category: Joi.string().allow(null),
  description: Joi.string()
    .max(250)
    .allow(''),
  disabled: Joi.bool(),
  private: Joi.bool(),
  defaultLanguage: Joi.string()
    .min(2)
    .max(3),
  languages: Joi.array().items(
    Joi.string()
      .min(2)
      .max(3)
  ),
  details: {
    website: Joi.string()
      .uri()
      .optional()
      .allow(''),
    termsConditions: Joi.string()
      .uri()
      .optional()
      .allow(''),
    privacyPolicy: Joi.string()
      .uri()
开发者ID:alexsandrocruz,项目名称:botpress,代码行数:30,代码来源:validation.ts

示例5: resolve

  Joi.object()
    .keys({
      pathname: Joi.string().regex(/^\//, 'start with a /'),
      hash: Joi.string().regex(/^\//, 'start with a /'),
    })
    .default();

const defaultRelativeToConfigPath = (path: string) => {
  const makeDefault: any = (_: any, options: any) => resolve(dirname(options.context.path), path);
  makeDefault.description = `<config.js directory>/${path}`;
  return makeDefault;
};

export const schema = Joi.object()
  .keys({
    testFiles: Joi.array()
      .items(Joi.string())
      .when('$primary', {
        is: true,
        then: Joi.required(),
        otherwise: Joi.any().default([]),
      }),

    excludeTestFiles: Joi.array()
      .items(Joi.string())
      .default([]),

    suiteTags: Joi.object()
      .keys({
        include: Joi.array()
          .items(Joi.string())
开发者ID:elastic,项目名称:kibana,代码行数:31,代码来源:schema.ts

示例6:

import Joi from 'joi'

export const ID_REGEX = /^[a-zA-Z0-9]+[A-Z0-9_-]{2,}$/i

export const SlotsCreateSchema = Joi.object().keys({
  name: Joi.string().required(),
  // @deprecated >11
  entity: Joi.string().optional(),
  entities: Joi.array()
    .items(Joi.string())
    .required(),
  color: Joi.number().required(),
  id: Joi.string().required()
})

export const IntentDefCreateSchema = Joi.object().keys({
  name: Joi.string().required(),
  utterances: Joi.array()
    .items(Joi.string())
    .default([]),
  slots: Joi.array()
    .items(SlotsCreateSchema)
    .default([]),
  contexts: Joi.array()
    .items(Joi.string())
    .default(['global'])
})

const EntityDefOccurenceSchema = Joi.object().keys({
  name: Joi.string().required(),
  synonyms: Joi.array().items(Joi.string())
开发者ID:alexsandrocruz,项目名称:botpress,代码行数:31,代码来源:validation.ts

示例7: propertyToJoi

function propertyToJoi(property: Property, optional = false) {
  let joiRule

  switch (property.type) {
    case 'action':
      joiRule = joi.alternatives([
        joi.object({
          type: joi
            .string()
            .required()
            .only('call'),
          deviceId: joi.string().required(),
          interfaceId: joi.string().required(),
          method: joi.string().required(),
          arguments: joi.object().required(),
        }),
        joi.object({
          type: joi
            .string()
            .required()
            .only('modification'),
          deviceId: joi.string().required(),
          interfaceId: joi.string().required(),
          statusId: joi.string().required(),
          value: joi.any().required(),
        }),
      ])
      break
    case 'array':
      joiRule = joi.array().items(propertyToJoi(property.items, true))
      break
    case 'boolean':
      joiRule = joi.boolean()
      break
    case 'device':
      joiRule = joi.string()
      break
    case 'enum':
      joiRule = joi.alternatives(joi.string(), joi.number())
      // .only(property.values.map(value => value.value.toString()))
      break
    case 'modification':
      joiRule = joi.object({
        deviceId: joi.string().required(),
        interfaceId: joi.string().required(),
        statusId: joi.string().required(),
        value: joi.any().required(),
      })
      break
    case 'integer':
      joiRule = joi.number().integer()
    // fall through
    case 'number':
      let numberJoiRule: joi.NumberSchema = joiRule || joi.number()
      if (property.min !== undefined) {
        numberJoiRule = numberJoiRule.min(property.min)
      }
      if (property.max !== undefined) {
        numberJoiRule = numberJoiRule.max(property.max)
      }

      joiRule = numberJoiRule
      break
    case 'string':
      joiRule = joi.string()
      break
  }

  if (!property.optional && !optional) {
    joiRule = joiRule.required()
  }

  return joiRule
}
开发者ID:Pajn,项目名称:RAXA,代码行数:74,代码来源:validations.ts

示例8: coerce

                'map.value',
                { entryKey, reason: valueError },
                state,
                options
              );
            }

            result.set(validatedEntryKey, validatedEntryValue);
          }

          return result as any;
        },
      },
    ],
  },
  {
    name: 'array',

    base: Joi.array(),
    coerce(value: any, state: State, options: ValidationOptions) {
      // If value isn't defined, let Joi handle default value if it's defined.
      if (value !== undefined && !Array.isArray(value)) {
        return this.createError('array.base', { value }, state, options);
      }

      return value;
    },
    rules: [anyCustomRule],
  },
]) as JoiRoot;
开发者ID:austec-automation,项目名称:kibana,代码行数:30,代码来源:index.ts

示例9: beats

 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License;
 * you may not use this file except in compliance with the Elastic License.
 */
import Joi from 'joi';
import { resolve } from 'path';
import { PLUGIN } from './common/constants';
import { CONFIG_PREFIX } from './common/constants/plugin';
import { initServerWithKibana } from './server/kibana.index';
import { KibanaLegacyServer } from './server/lib/adapters/framework/adapter_types';

const DEFAULT_ENROLLMENT_TOKENS_TTL_S = 10 * 60; // 10 minutes

export const config = Joi.object({
  enabled: Joi.boolean().default(true),
  defaultUserRoles: Joi.array()
    .items(Joi.string())
    .default(['superuser']),
  encryptionKey: Joi.string().default('xpack_beats_default_encryptionKey'),
  enrollmentTokensTtlInSeconds: Joi.number()
    .integer()
    .min(1)
    .max(10 * 60 * 14) // No more then 2 weeks for security reasons
    .default(DEFAULT_ENROLLMENT_TOKENS_TTL_S),
}).default();

export function beats(kibana: any) {
  return new kibana.Plugin({
    id: PLUGIN.ID,
    require: ['kibana', 'elasticsearch', 'xpack_main'],
    publicDir: resolve(__dirname, 'public'),
开发者ID:elastic,项目名称:kibana,代码行数:31,代码来源:index.ts

示例10:

        .only('string', 'integer', 'number', 'boolean', 'object')
        .required(),

      optional: joi.boolean(),
      modifiable: joi.boolean(),
    })
    .when(joi.ref('type'), {
      is: 'boolean',
      then: joi.object({
        defaultValue: joi.boolean(),
      }),
    })
    .when(joi.ref('type'), {
      is: 'device',
      then: joi.object({
        interfaceIds: joi.array().items(joi.string().required()),
        deviceClassIds: joi.array().items(joi.string().required()),
      }),
    })
    .when(joi.ref('type'), {
      is: 'number',
      then: joi.object({
        min: joi.number(),
        max: joi.number(),
        unit: joi.string(),
        defaultValue: joi.number(),
      }),
    })
    .when(joi.ref('type'), {
      is: 'integer',
      then: joi.object({
开发者ID:Pajn,项目名称:RAXA,代码行数:31,代码来源:validations.ts


注:本文中的joi.array函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。