本文整理汇总了TypeScript中yup.mixed函数的典型用法代码示例。如果您正苦于以下问题:TypeScript mixed函数的具体用法?TypeScript mixed怎么用?TypeScript mixed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mixed函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: switch
const renderable = yup.lazy(value => {
switch (typeof value) {
case "number":
return yup.number();
case "string":
return yup.string();
default:
return yup.mixed();
}
});
开发者ID:j-f1,项目名称:forked-DefinitelyTyped,代码行数:10,代码来源:yup-tests.ts
示例2:
path: "path",
errors: ["error"],
inner: [yup.ValidationError("error", true, "path")],
type: "date",
value: { start: "2017-11-10" }
};
error.value = "value";
error.value = true;
error.value = 5;
error.value = { name: "value" };
error.type = {};
error.type = [];
error.errors = ["error"];
// mixed
let mixed: MixedSchema = yup.mixed();
mixed.clone();
mixed.label("label");
mixed.meta({ meta: "value" });
mixed.describe().label;
mixed.describe().meta;
mixed.describe().tests;
mixed.describe().type;
mixed.concat(yup.string());
mixed.validate({});
mixed.validate({ hello: "world" }, { strict: true }).then(value => value);
mixed.validateSync({ hello: "world" }, { strict: true });
mixed.validateAt("path", {}, { strict: true, context: {} });
mixed
.validateAt("path", {}, { strict: true, context: {} })
.then(value => value);
开发者ID:j-f1,项目名称:forked-DefinitelyTyped,代码行数:31,代码来源:yup-tests.ts
示例3: number
'Must be a valid private IPv4 address.'
)
.required('IP address is required.'),
port: number()
.typeError('Port must be a number.')
.required('Port is required.')
.min(1, 'Port must be between 1 and 65535.')
.max(65535, 'Port must be between 1 and 65535.'),
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', 'backup', '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() }),
开发者ID:linode,项目名称:manager,代码行数:31,代码来源:nodebalancers.schema.ts
示例4: string
address: string()
.matches(/^192\.168\.\d{1,3}\.\d{1,3}$/, 'Must be a valid IPv4 address.')
.required('IP address is required.'),
port: number().typeError("Port must be a number.")
.required('Port is required.')
.min(1, "Port must be between 1 and 65535.")
.max(65535, "Port must be between 1 and 65535."),
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"]),
开发者ID:displague,项目名称:manager,代码行数:29,代码来源:nodebalancers.schema.ts
示例5: boolean
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(
[null, 'read_only', 'read_write'],
'Permissions must be null, read_only, or read_write.'
)
});
export const UpdateGrantSchema = object({
global: object(),
linode: array().of(GrantSchema),
domain: array().of(GrantSchema),
nodebalancer: array().of(GrantSchema),
image: array().of(GrantSchema),
longview: array().of(GrantSchema),
stackscript: array().of(GrantSchema),
volume: array().of(GrantSchema)
});
开发者ID:linode,项目名称:manager,代码行数:31,代码来源:account.schema.ts
示例6: boolean
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([null, 'read_only', 'read_write'],
"Permissions must be null, read_only, or read_write.")
})
export const UpdateGrantSchema = object({
global: object(),
linode: array().of(GrantSchema),
domain: array().of(GrantSchema),
nodebalancer: array().of(GrantSchema),
image: array().of(GrantSchema),
longview: array().of(GrantSchema),
stackscript: array().of(GrantSchema),
volume: array().of(GrantSchema),
});
开发者ID:displague,项目名称:manager,代码行数:30,代码来源:account.schema.ts
示例7: array
authorized_users: array().of(string()).notRequired()
});
const alerts = object({
cpu: number()
.typeError("CPU Usage must be a number")
.min(0, "Must be between 0 and 2000")
.max(2000, "Must be between 0 and 2000"),
network_in: number(),
network_out: number(),
transfer_quota: number(),
io: number(),
}).nullable(true);
const schedule = object({
day: mixed().oneOf(["Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"], "Invalid day value."),
window: mixed().oneOf(["W0", "W2", "W4", "W8", "W10",
"W12", "W14", "W16", "W18", "W20", "W22"], "Invalid schedule value."),
});
const backups = object({
schedule,
enabled: boolean(),
})
export const UpdateLinodeSchema = object({
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-_])+$/,
开发者ID:displague,项目名称:manager,代码行数:31,代码来源:linode.schema.ts
示例8: object
.notRequired()
});
const alerts = object({
cpu: number()
.typeError('CPU Usage must be a number')
.min(0, 'Must be between 0 and 2000')
.max(2000, 'Must be between 0 and 2000'),
network_in: number(),
network_out: number(),
transfer_quota: number(),
io: number()
}).nullable(true);
const schedule = object({
day: mixed().oneOf(
[
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday'
],
'Invalid day value.'
),
window: mixed().oneOf(
[
'W0',
'W2',
开发者ID:linode,项目名称:manager,代码行数:31,代码来源:linode.schema.ts
示例9: object
import { array, mixed, number, object, string } from 'yup';
export const importZoneSchema = object({
domain: string().required('Domain is required.'),
remote_nameserver: string().required('Remote nameserver is required.')
});
const domainSchemaBase = object().shape({
domain: string()
.matches(/([a-zA-Z0-9-_]+\.)+([a-zA-Z]{2,3}\.)?([a-zA-Z]{2,16}|XN--[a-zA-Z0-9]+)/, 'Domain is not valid.'),
status: mixed().oneOf(['disabled', 'active', 'edit_mode', 'has_errors']),
tags: array(),
description: string()
.min(1, 'Description must be between 1 and 255 characters.')
.max(255, 'Description must be between 1 and 255 characters.'),
retry_sec: number(),
master_ips: array().of(string()),
axfr_ips: array().of(string()),
expire_sec: number(),
refresh_sec: number(),
ttl_sec: number()
});
export const createDomainSchema = domainSchemaBase.shape({
domain: string()
.required('Domain is required.')
.matches(/([a-zA-Z0-9-_]+\.)+([a-zA-Z]{2,3}\.)?([a-zA-Z]{2,16}|XN--[a-zA-Z0-9]+)/, 'Domain is not valid.'),
type: mixed()
.required()
.oneOf(['master', 'slave']),
soa_email: string()
开发者ID:displague,项目名称:manager,代码行数:31,代码来源:domains.schema.ts
注:本文中的yup.mixed函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论