• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript yup.array函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中yup.array函数的典型用法代码示例。如果您正苦于以下问题:TypeScript array函数的具体用法?TypeScript array怎么用?TypeScript array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了array函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: function

import * as yup from 'yup';
import { setLocale } from 'yup/lib/customLocale';

// tslint:disable-next-line:no-duplicate-imports
import { reach, date, Schema, ObjectSchema, ValidationError, MixedSchema, SchemaDescription, TestOptions, ValidateOptions, NumberSchema } from 'yup';

// reach function
let schema = yup.object().shape({
    nested: yup.object().shape({
        arr: yup.array().of(
            yup.object().shape({ num: yup.number().max(4) })
        )
    })
  });
reach(schema, 'nested.arr.num');
reach(schema, 'nested.arr[].num');

// addMethod function
yup.addMethod<NumberSchema>(yup.number, 'minimum', function(this, minValue: number, message: string) {
    return this.min(minValue, message);
});
yup.addMethod(yup.date, 'newMethod', function(this: yup.DateSchema, date: Date, message?: string) {
    return this.max(date, message);
});

// ref function
schema = yup.object().shape({
    baz: yup.ref('foo.bar'),
    foo: yup.object().shape({
      bar: yup.string()
    }),
开发者ID:Dru89,项目名称:DefinitelyTyped,代码行数:31,代码来源:yup-tests.ts


示例2: function

    date,
    Schema,
    ObjectSchema,
    ValidationError,
    MixedSchema,
    SchemaDescription,
    TestOptions,
    ValidateOptions,
    NumberSchema,
    TestContext
} from "yup";

// reach function
let schema = yup.object().shape({
    nested: yup.object().shape({
        arr: yup.array().of(yup.object().shape({ num: yup.number().max(4) }))
    })
});
reach(schema, "nested.arr.num");
reach(schema, "nested.arr[].num");

// addMethod function
yup.addMethod<NumberSchema>(yup.number, "minimum", function(
    this,
    minValue: number,
    message: string
) {
    return this.min(minValue, message);
});
yup.addMethod(yup.date, "newMethod", function(
    this: yup.DateSchema,
开发者ID:j-f1,项目名称:forked-DefinitelyTyped,代码行数:31,代码来源:yup-tests.ts


示例3: number

  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()
    .when('protocol', { is: 'https', then: string()
      .required('SSL certificate is required when using HTTPS.') }),
  stickiness: mixed().oneOf(["none", "table", "http_cookie"]),
  nodes: array()
    .of(nodeBalancerConfigNodeSchema).required().min(1, "You must provide at least one back end node."),
});

export const UpdateNodeBalancerConfigSchema = 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,代码行数:31,代码来源:nodebalancers.schema.ts


示例4: 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


示例5:

import * as Yup from 'yup'

export const mappingValidationSchema = Yup.object().shape({
    method: Yup.string()
        .required('Request method is required'),
    queryParameters: Yup.array().of(Yup.object().shape({
        key: Yup.string()
            .required('Query parameter name is required'),
        value: Yup.string()
            .required('Query parameter value is required'),
    })),
    requestHeaders: Yup.array().of(Yup.object().shape({
        key: Yup.string()
            .required('Header name is required'),
        value: Yup.string()
            .required('Header value is required'),
    })),
    requestCookies: Yup.array().of(Yup.object().shape({
        key: Yup.string()
            .required('Cookie name is required'),
        value: Yup.string()
            .required('Cookie value is required'),
    })),
    responseStatus: Yup.number()
        .min(100, 'Response status code is invalid')
        .max(527, 'Response status code is invalid')
        .required('Response status code is required'),
    responseHeaders: Yup.array().of(Yup.object().shape({
        key: Yup.string()
            .required('Header name is required'),
        value: Yup.string()
开发者ID:manishshanker,项目名称:wiremock-ui,代码行数:31,代码来源:validation.ts


示例6: 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


示例7: 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


示例8: object

export const CreateVolumeSchema = object({
  region: string()
    .when('linode_id', {
      is: (id) => id === undefined || id === '',
      then: string().required("Must provide a region or a Linode ID."),
    }),
  linode_id: number(),
  size: createSizeValidation(10),
  label: string()
    .required("Label is required.")
    .ensure()
    .trim()
    .min(1, "Label must be between 1 and 32 characters.")
    .max(32, "Label must be 32 characters or less."),
  config_id: number().typeError("Config ID must be a number."),
  tags: array().of(string())
});

export const CloneVolumeSchema = object({
  label: string().required()
})

export const ResizeVolumeSchema = (minSize: number = 10) => object({
  size: createSizeValidation(minSize),
})

export const UpdateVolumeSchema = object({
  label: string().required()
})

export const AttachVolumeSchema = object({
开发者ID:displague,项目名称:manager,代码行数:31,代码来源:volumes.schema.ts


示例9: 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)
});

export const UpdateAccountSettingsSchema = object({
  network_helper: boolean(),
  backups_enabled: boolean(),
  managed: boolean()
});
开发者ID:linode,项目名称:manager,代码行数:30,代码来源:account.schema.ts



注:本文中的yup.array函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript yup.boolean函数代码示例发布时间:2022-05-25
下一篇:
TypeScript yup.addMethod函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap