本文整理汇总了TypeScript中yup.boolean函数的典型用法代码示例。如果您正苦于以下问题:TypeScript boolean函数的具体用法?TypeScript boolean怎么用?TypeScript boolean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了boolean函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: Date
numSchema.min(5, "message");
numSchema.max(5, "message");
numSchema.positive();
numSchema.negative();
numSchema.lessThan(5);
numSchema.moreThan(5);
numSchema.integer();
numSchema.truncate();
numSchema.round("floor");
numSchema
.validate(5, { strict: true })
.then(value => value)
.catch(err => err);
// Boolean Schema
const boolSchema = yup.boolean();
boolSchema.isValid(true); // => true
// Date Schema
const dateSchema = yup.date();
dateSchema.isValid(new Date()); // => true
dateSchema.min(new Date());
dateSchema.min("2017-11-12");
dateSchema.min(new Date(), "message");
dateSchema.min("2017-11-12", "message");
dateSchema.max(new Date());
dateSchema.max("2017-11-12");
dateSchema.max(new Date(), "message");
dateSchema.max("2017-11-12", "message");
// Array Schema
开发者ID:j-f1,项目名称:forked-DefinitelyTyped,代码行数:31,代码来源:yup-tests.ts
示例2: number
weight: number().typeError("Weight must be a number.")
.min(1, `Weight must be between 1 and 255.`)
.max(255, `Weight must be between 1 and 255.`),
mode: mixed()
.oneOf(['accept', 'reject', 'drain'])
});
export const createNodeBalancerConfigSchema = object({
algorithm: mixed().oneOf(["roundrobin", "leastconn", "source"]),
check_attempts: number(),
check_body: string()
.when('check', { is: 'http_body', then: string().required() }),
check_interval: number().typeError("Check interval must be a number."),
check_passive: boolean(),
check_path: string().matches(/\/.*/)
.when('check', { is: 'http', then: string().required() })
.when('check', { is: 'http_body', then: string().required() }),
check_timeout: number().typeError("Timeout must be a number.").integer(),
check: mixed().oneOf(["none", "connection", "http", "http_body"]),
cipher_suite: mixed().oneOf(["recommended", "legacy"]),
port: number().integer()
.required('Port is required')
.min(1, "Port must be between 1 and 65535.")
.max(65535, "Port must be between 1 and 65535."),
protocol: mixed().oneOf(['http', 'https', 'tcp']),
ssl_key: string()
.when('protocol', { is: 'https', then: string()
.required('SSL key is required when using HTTPS.') }),
ssl_cert: string()
开发者ID:displague,项目名称:manager,代码行数:30,代码来源:nodebalancers.schema.ts
示例3: object
import { array, boolean, object, string } from 'yup';
export const createPersonalAccessTokenSchema = object({
scopes: string(),
expiry: string(),
label: string()
.min(1, 'Label must be between 1 and 100 characters.')
.max(100, 'Label must be between 1 and 100 characters.')
});
export const createSSHKeySchema = object({
label: string()
.required('Label is required.')
.min(1, 'Label must be between 1 and 64 characters.')
.max(64, 'Label must be between 1 and 64 characters.')
.trim(),
ssh_key: string()
});
export const updateProfileSchema = object({
email: string().email(),
timezone: string(),
email_notifications: boolean(),
authorized_keys: array().of(string()),
restricted: boolean(),
two_factor_auth: boolean(),
lish_auth_method: string().oneOf(['password_keys', 'keys_only', 'disabled'])
});
开发者ID:linode,项目名称:manager,代码行数:28,代码来源:profile.schema.ts
示例4: object
import { array, boolean, object, string } from 'yup';
export const stackScriptSchema = object({
script: string().required('Script is required.'),
label: string()
.required('Label is required.')
.min(3, 'Label must be between 3 and 128 characters.')
.max(128, 'Label must be between 3 and 128 characters.'),
images: array()
.of(string())
.required('An image is required.'),
description: string(),
is_public: boolean(),
rev_note: string()
});
export const updateStackScriptSchema = object({
script: string(),
label: string()
.min(3, 'Label must be between 3 and 128 characters.')
.max(128, 'Label must be between 3 and 128 characters.'),
images: array()
.of(string())
.min(1, 'An image is required.'),
description: string(),
is_public: boolean(),
rev_note: string()
});
开发者ID:linode,项目名称:manager,代码行数:28,代码来源:stackscripts.schema.ts
示例5: object
import { array, boolean, number, object, string } from 'yup';
export const updateIPSchema = object().shape({
rdns: string()
.notRequired()
.nullable(true)
});
export const allocateIPSchema = object().shape({
type: string()
.required()
.matches(
/^ipv4$/,
'Only IPv4 address may be allocated through this endpoint.'
),
public: boolean().required(),
linode_id: number().required()
});
export const assignAddressesSchema = object().shape({
region: string().required(),
assignments: array()
.of(object())
.required()
});
export const shareAddressesSchema = object().shape({
linode_id: number().required(),
ips: array().of(string())
});
开发者ID:linode,项目名称:manager,代码行数:30,代码来源:networking.schema.ts
示例6: number
.max(9999, 'Expiration year must be four digits.'),
expiry_month: number()
.required('Expiration month is required.')
.min(1, 'Expiration month must be a number from 1 to 12.')
.max(12, 'Expiration month must be a number from 1 to 12.')
});
export const CreateUserSchema = object({
username: string()
.required('Username is required.')
.min(3, 'Username must be between 3 and 32 characters.')
.max(32, 'Username must be between 3 and 32 characters.'),
email: string()
.required('Email address is required.')
.email('Must be a valid email address.'),
restricted: boolean().required(
'You must indicate if this user should have restricted access.'
)
});
export const UpdateUserSchema = object({
username: string()
.min(3, 'Username must be between 3 and 32 characters.')
.max(32, 'Username must be between 3 and 32 characters.'),
email: string().email('Must be a valid email address.'),
restricted: boolean()
});
const GrantSchema = object({
id: number().required('ID is required.'),
permissions: mixed().oneOf(
开发者ID:linode,项目名称:manager,代码行数:31,代码来源:account.schema.ts
示例7: object
});
export const CreateLinodeSchema = object({
type: string()
.ensure()
.required('Plan is required.'),
region: string()
.ensure()
.required('Region is required.'),
stackscript_id: number().notRequired(),
backup_id: number().notRequired(),
swap_size: number().notRequired(),
image: string().nullable(true),
root_pass: string().notRequired(),
authorized_keys: array().of(string()).notRequired(),
backups_enabled: boolean().notRequired(),
stackscript_data,
booted: boolean().notRequired(),
label: string().nullable(true)
.min(3, "Label must contain between 3 and 32 characters.")
.max(32,"Label must contain between 3 and 32 characters.")
.matches(/^[a-zA-Z]((?!--|__)[a-zA-Z0-9-_])+$/,
"Label can only use alphanumeric characters, dashes, or underscores."),
tags: array().of(string()).notRequired(),
private_ip: boolean().notRequired(),
authorized_users: array().of(string()).notRequired()
});
const alerts = object({
cpu: number()
.typeError("CPU Usage must be a number")
开发者ID:displague,项目名称:manager,代码行数:31,代码来源:linode.schema.ts
示例8: object
export const CreateLinodeSchema = object({
type: string()
.ensure()
.required('Plan is required.'),
region: string()
.ensure()
.required('Region is required.'),
stackscript_id: number().notRequired(),
backup_id: number().notRequired(),
swap_size: number().notRequired(),
image: string().nullable(true),
root_pass: string().notRequired(),
authorized_keys: array()
.of(string())
.notRequired(),
backups_enabled: boolean().notRequired(),
stackscript_data,
booted: boolean().notRequired(),
label: string()
.nullable(true)
.min(3, 'Label must contain between 3 and 32 characters.')
.max(32, 'Label must contain between 3 and 32 characters.'),
tags: array()
.of(string())
.notRequired(),
private_ip: boolean().notRequired(),
authorized_users: array()
.of(string())
.notRequired()
});
开发者ID:linode,项目名称:manager,代码行数:30,代码来源:linode.schema.ts
注:本文中的yup.boolean函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论