當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript yup.boolean函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。