當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript joi.bool函數代碼示例

本文整理匯總了TypeScript中joi.bool函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript bool函數的具體用法?TypeScript bool怎麽用?TypeScript bool使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了bool函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: initStatusApi

export function initStatusApi(server: Server) {
  server.route({
    method: 'GET',
    path: `${ROOT}/server`,
    options: {
      validate: {
        query: Joi.object().keys({
          _debug: Joi.bool()
        })
      }
    },
    handler: req => {
      const setup = setupRequest(req);
      return getServerStatus({ setup }).catch(defaultErrorHandler);
    }
  });

  server.route({
    method: 'GET',
    path: `${ROOT}/agent`,
    options: {
      validate: {
        query: Joi.object().keys({
          _debug: Joi.bool()
        })
      }
    },
    handler: req => {
      const setup = setupRequest(req);
      return getAgentStatus({ setup }).catch(defaultErrorHandler);
    }
  });
}
開發者ID:njd5475,項目名稱:kibana,代碼行數:33,代碼來源:status_check.ts

示例2: reply

export const createBeatUpdateRoute = (libs: CMServerLibs) => ({
  method: 'PUT',
  path: '/api/beats/agent/{beatId}',
  licenseRequired: true,
  config: {
    auth: {
      mode: 'optional',
    },
    validate: {
      headers: Joi.object({
        'kbn-beats-access-token': Joi.string(),
      }).options({
        allowUnknown: true,
      }),
      params: Joi.object({
        beatId: Joi.string(),
      }),
      payload: Joi.object({
        active: Joi.bool(),
        ephemeral_id: Joi.string(),
        host_name: Joi.string(),
        local_configuration_yml: Joi.string(),
        metadata: Joi.object(),
        name: Joi.string(),
        type: Joi.string(),
        version: Joi.string(),
      }),
    },
  },
  handler: async (request: FrameworkRequest, reply: any) => {
    const { beatId } = request.params;
    const accessToken = request.headers['kbn-beats-access-token'];
    const remoteAddress = request.info.remoteAddress;
    const userOrToken = accessToken || request.user;

    if (request.user.kind === 'unauthenticated' && request.payload.active !== undefined) {
      return reply({ message: 'access-token is not a valid auth type to change beat status' }).code(
        401
      );
    }

    try {
      const status = await libs.beats.update(userOrToken, beatId, {
        ...request.payload,
        host_ip: remoteAddress,
      });

      switch (status) {
        case 'beat-not-found':
          return reply({ message: 'Beat not found', success: false }).code(404);
        case 'invalid-access-token':
          return reply({ message: 'Invalid access token', success: false }).code(401);
      }

      reply({ success: true }).code(204);
    } catch (err) {
      return reply(wrapEsError(err));
    }
  },
});
開發者ID:salihkardan,項目名稱:kibana,代碼行數:60,代碼來源:update.ts

示例3:

export const withDefaultValidators = (validators = {}) => {
  return Joi.object().keys({
    _debug: Joi.bool(),
    start: dateValidation,
    end: dateValidation,
    uiFiltersES: Joi.string(),
    ...validators
  });
};
開發者ID:elastic,項目名稱:kibana,代碼行數:9,代碼來源:input_validation.ts

示例4: initGetPrivilegesApi

export function initGetPrivilegesApi(
  server: Record<string, any>,
  routePreCheckLicenseFn: () => void
) {
  server.route({
    method: 'GET',
    path: '/api/security/privileges',
    handler(req: Record<string, any>) {
      const { authorization } = server.plugins.security;
      const privileges: RawKibanaPrivileges = authorization.privileges.get();

      if (req.query.includeActions) {
        return privileges;
      }

      return {
        global: Object.keys(privileges.global),
        space: Object.keys(privileges.space),
        features: Object.entries(privileges.features).reduce(
          (acc, [featureId, featurePrivileges]) => {
            return {
              ...acc,
              [featureId]: Object.keys(featurePrivileges),
            };
          },
          {}
        ),
        reserved: Object.keys(privileges.reserved),
      };
    },
    config: {
      pre: [routePreCheckLicenseFn],
      validate: {
        query: Joi.object().keys({
          includeActions: Joi.bool(),
        }),
      },
    },
  });
}
開發者ID:spalger,項目名稱:kibana,代碼行數:40,代碼來源:get.ts

示例5: buildValidationSchema

function buildValidationSchema(application: string, actions: string[], resources: string[]) {
  const actionValidationSchema = buildActionsValidationSchema(actions);

  const resourceValidationSchema = Joi.object({
    ...resources.reduce((acc, resource) => {
      return {
        ...acc,
        [resource]: actionValidationSchema,
      };
    }, {}),
  }).required();

  return Joi.object({
    username: Joi.string().required(),
    has_all_requested: Joi.bool(),
    cluster: Joi.object(),
    application: Joi.object({
      [application]: resourceValidationSchema,
    }).required(),
    index: Joi.object(),
  }).required();
}
開發者ID:spalger,項目名稱:kibana,代碼行數:22,代碼來源:validate_es_response.ts

示例6: registerRoutes

export const Validation = {
    UpdateAppConfig: joi.object().keys({
        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

示例7:

 ...actions.reduce<Record<string, any>>((acc, action) => {
   return {
     ...acc,
     [action]: Joi.bool().required(),
   };
 }, {}),
開發者ID:spalger,項目名稱:kibana,代碼行數:6,代碼來源:validate_es_response.ts

示例8: async

export const createBeatUpdateRoute = (libs: CMServerLibs) => ({
  method: 'PUT',
  path: '/api/beats/agent/{beatId}',
  licenseRequired: REQUIRED_LICENSES,
  requiredRoles: ['beats_admin'],
  config: {
    validate: {
      headers: Joi.object({
        'kbn-beats-access-token': Joi.string(),
      }).options({
        allowUnknown: true,
      }),
      params: Joi.object({
        beatId: Joi.string(),
      }),
      payload: Joi.object({
        active: Joi.bool(),
        ephemeral_id: Joi.string(),
        host_name: Joi.string(),
        local_configuration_yml: Joi.string(),
        metadata: Joi.object(),
        name: Joi.string(),
        type: Joi.string(),
        version: Joi.string(),
      }),
    },
  },
  handler: async (
    request: FrameworkRequest
  ): Promise<BaseReturnType | ReturnTypeUpdate<CMBeat>> => {
    const { beatId } = request.params;
    const accessToken = request.headers['kbn-beats-access-token'];
    const remoteAddress = request.info.remoteAddress;
    const userOrToken = accessToken || request.user;

    if (request.user.kind === 'unauthenticated' && request.payload.active !== undefined) {
      return {
        error: {
          message: 'access-token is not a valid auth type to change beat status',
          code: 401,
        },
        success: false,
      };
    }

    const status = await libs.beats.update(userOrToken, beatId, {
      ...request.payload,
      host_ip: remoteAddress,
    });

    switch (status) {
      case 'beat-not-found':
        return {
          error: {
            message: 'Beat not found',
            code: 404,
          },
          success: false,
        };
      case 'invalid-access-token':
        return {
          error: {
            message: 'Invalid access token',
            code: 401,
          },
          success: false,
        };
    }

    const beat = await libs.beats.getById(internalUser, beatId);

    return {
      item: beat,
      action: 'updated',
      success: true,
    };
  },
});
開發者ID:elastic,項目名稱:kibana,代碼行數:78,代碼來源:update.ts

示例9:

    .max(50)
    .allow('')
    .optional(),
  // tslint:disable-next-line:no-null-keyword
  category: Joi.string().allow(null),
  description: Joi.string()
    .max(250)
    .allow(''),
  pipeline_status: {
    current_stage: {
      promoted_by: Joi.string(),
      promoted_on: Joi.date(),
      id: Joi.string()
    }
  },
  locked: Joi.bool()
})

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)
開發者ID:alexsandrocruz,項目名稱:botpress,代碼行數:31,代碼來源:validation.ts

示例10:

    // https://webpack.js.org/configuration/entry-context/#entry
    'entry': Joi.alternatives(
      Joi.string(),
      Joi.array().items(Joi.alternatives(
        Joi.string(),
        Joi.object().pattern(
          Joi.string(),
          Joi.alternatives(
            Joi.string(),
            Joi.array().items(Joi.string())
          )
        )
      )),
      Joi.func()
    ),
    'enableSourceMap': Joi.bool(),
    'enableExtract': Joi.bool(),
    'cssLoaderOption': Joi.object(), // 第三方配置
    'styleLoaderOption': Joi.object(), // 第三方配置
    'sassLoaderOption': Joi.object(), // 第三方配置
    'lessLoaderOption': Joi.object(), // 第三方配置
    'stylusLoaderOption': Joi.object(), // 第三方配置
    'mediaUrlLoaderOption': Joi.object(), // 第三方配置
    'fontUrlLoaderOption': Joi.object(), // 第三方配置
    'imageUrlLoaderOption': Joi.object(), // 第三方配置
    'miniCssExtractPluginOption': Joi.object(), // 第三方配置

    'module': Joi.object().keys({
      'postcss': Joi.object().pattern(
        Joi.string(),
        Joi.object().keys({
開發者ID:YangShaoQun,項目名稱:taro,代碼行數:31,代碼來源:configSchema.ts


注:本文中的joi.bool函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。