本文整理汇总了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);
}
});
}
示例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));
}
},
});
示例3:
export const withDefaultValidators = (validators = {}) => {
return Joi.object().keys({
_debug: Joi.bool(),
start: dateValidation,
end: dateValidation,
uiFiltersES: Joi.string(),
...validators
});
};
示例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(),
}),
},
},
});
}
示例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();
}
示例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,
示例7:
...actions.reduce<Record<string, any>>((acc, action) => {
return {
...acc,
[action]: Joi.bool().required(),
};
}, {}),
示例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,
};
},
});
示例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)
示例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({