本文整理匯總了TypeScript中joi-browser.string函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript string函數的具體用法?TypeScript string怎麽用?TypeScript string使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了string函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test
test('Form => validateFormField() returns true when the field we want to validate is valid', () => {
form = new Form([
{ fieldName: 'jobTitle', validator: Joi.string().min(2).max(60).required(), type: ValidatorType.JOI },
{ fieldName: 'isPayingJob', validator: Joi.bool().required(), type: ValidatorType.JOI }
])
expect(form.validateFormField('jobTitle', 'Valid Job Title')).toBe(true);
})
示例2:
import * as Joi from "joi-browser";
import { is } from "../../util";
interface BotResponse {
id: string;
error?: void;
result: {
[key: string]: any;
method: string;
};
};
let goodResponseValidator = Joi.object().keys({
id: Joi.string(),
result: Joi.object(),
error: Joi.any().allow(null, false)
});
// Type guard function to do type checking at runtime.
let isBotResponse = is<BotResponse>(goodResponseValidator);
export interface RPCError {
error: string;
method: string;
}
export interface BotErrorResponse {
id: string;
result?: void;
error: RPCError;
};