當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。