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


TypeScript joi.any函数代码示例

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


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

示例1: resolve

     arguments: {type: GraphQLJSON},
   },
   writeRules: false,
   async resolve(_, call: Call, {storage, pluginSupervisor}: Context) {
     await pluginSupervisor.callDevice(call)
     const state = storage.getState()
     return state.devices[call.deviceId]
   },
 },
 setDeviceStatus: {
   type: [DeviceStatusType],
   validate: joi.object({
     deviceId: joi.string(),
     interfaceId: joi.string(),
     statusId: joi.string(),
     value: joi.any(),
   }),
   args: {
     value: {type: GraphQLJSON},
   },
   writeRules: false,
   async resolve(
     _,
     modification: Modification,
     context: Context,
   ): Promise<Array<DeviceStatus> | undefined> {
     if (
       modification.interfaceId === 'Power' &&
       modification.value === 'toggle'
     ) {
       modification.value = !getValue(context.storage.getState().status, [
开发者ID:Pajn,项目名称:RAXA,代码行数:31,代码来源:device.ts

示例2: registerRoutes

        label: joi.object().keys({
            text: joi.string().label("Label"),
            placement: joi.string().only("top", "right", "bottom", "left").label("Label placement"),
            textAlignment: joi.string().only("left", "right").label("Label text alignment"),
            classes: joi.string().optional().label("Label CSS classes"),
        }),
        input: joi.object().keys({
            classes: joi.string().optional().label("Text field CSS classes"),
            placeholder: joi.string().optional().label("Text field placeholder"),
        }),
        format: joi.string().only("mm/dd/yyyy", "dd/mm/yyyy").label("Format"),
        maxDays: joi.number().label("Maximum allowed days"),
        placement: joi.string().only("left", "right", "center"),
        allowChangeFromCheckout: joi.bool(),
        addPickerToCheckout: joi.bool(),
        error: joi.any().strip(),
        isSaving: joi.any().strip(),
    })
}

export function registerRoutes(server: Server)
{
    server.route({
        method: "OPTIONS",
        path: Routes.AppConfig,
        config: {
            auth: false,
            plugins: {
                crumb: false,
            }
        },
开发者ID:nozzlegear,项目名称:deliver-on,代码行数:31,代码来源:api-v1-routes.ts

示例3: label

'use strict';

import * as Joi from 'joi';
import * as joiAssert from 'joi-assert';

import * as model from './model';
import * as schema from './schema';
import * as regex from './regex';

export let ok = joiAssert.bake(Joi.any());
export let number = joiAssert.bake(Joi.number());
export let string = joiAssert.bake(Joi.string());
export let object = joiAssert.bake(Joi.object());
export let array = joiAssert.bake(Joi.array());
export let uri = joiAssert.bake(schema.uri);
export let semver = joiAssert.bake(schema.semver);

export function label(obj: any, message?: string): model.Label {
	return joiAssert(obj, schema.label, message);
}
export function project(obj: any, message?: string): model.Project {
	return joiAssert(obj, schema.project, message);
}
export function person(obj: any, message?: string): model.Person {
	return joiAssert(obj, schema.person, message);
}
export function repository(obj: any, message?: string): model.Repository {
	return joiAssert(obj, schema.repository, message);
}
export function header(obj: any, message?: string): model.Header {
	return joiAssert(obj, schema.header, message);
开发者ID:DefinitelyTyped,项目名称:definition-header,代码行数:31,代码来源:assertion.ts

示例4:

import * as Joi from 'joi'

export const positiveInt = Joi.number().integer().min(0).optional()
const _id = Joi.number().integer().min(0).description('Unique id')


/**
 * Persisted and non persisted version of types are separated in order
 * to generate accurate swagger descriptions
 */
export const id: Joi.SchemaMap = { id: _id }
export const idPersisted: Joi.SchemaMap = {id: _id.required() }

export const timestamps: Joi.SchemaMap = {
  created_at: Joi.date().description('Creation date'),
  updated_at: Joi.date().description('Last update')
}

export const timestampsRequired: Joi.SchemaMap = {
  created_at: Joi.date().required().description('Creation date'),
  updated_at: Joi.date().required().description('Last update')
}

export const bool = Joi.any().valid([0, 1, true, false])
export const saneString = Joi.string().max(255).replace(/\0/gi, '')
export const saneText = Joi.string().max(1024).replace(/\0/gi, '')
开发者ID:lambrojos,项目名称:hapi-common,代码行数:26,代码来源:basic_types.ts

示例5:

let schema = {
  config: {
    debug: Joi.boolean(),
    server: {
      game: Joi.string().required(),
      address: Joi.string().required(),
      port: Joi.number().required(),
      authentication: {
        username: Joi.string().required(),
        password: Joi.string()
      }
    },
    masteradmins: Joi.array().items(Joi.string()),
    db: {
      debug: Joi.any().optional(),
      dialect: Joi.string().valid('mysql', 'mssql', 'sqlite', 'postgres'),
      database: Joi.string(),
      authentication: {
        username: Joi.any().optional(),
        password: Joi.any().optional()
      }, pool: {
        max: Joi.number().required(),
        min: Joi.number().required(),
        idle: Joi.number().required()
      },
      mysql: {
        host: Joi.string().required(),
        port: Joi.number().required()
      },
      mssql: {
开发者ID:tomvlk,项目名称:ManiaJS,代码行数:30,代码来源:configuration.ts

示例6: resolve

    .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())
          .default([]),
        exclude: Joi.array()
          .items(Joi.string())
          .default([]),
      })
开发者ID:elastic,项目名称:kibana,代码行数:31,代码来源:schema.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


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