当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript validator.isLength函数代码示例

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


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

示例1: isString

userSchema.path('name').validate(function(name: string) {
	// this gets default from username if not set anyway.
	if (this.isNew) {
		return true;
	}
	return isString(name) && isLength(name, 3, 30);
}, 'Name must be between 3 and 30 characters.');
开发者ID:freezy,项目名称:node-vpdb,代码行数:7,代码来源:user.schema.ts

示例2:

userSchema.path('password_hash').validate(function() {
	// here we check the length. remember that the virtual _password field is
	// the one that triggers the hashing.
	if (this._password && isString(this._password) && !isLength(this._password, 6)) {
		this.invalidate('password', 'Password must be at least 6 characters.');
	}
}, null);
开发者ID:freezy,项目名称:node-vpdb,代码行数:7,代码来源:user.schema.ts

示例3: isActorPublicKeyValid

function isActorPublicKeyValid (publicKey: string) {
  return exists(publicKey) &&
    typeof publicKey === 'string' &&
    publicKey.startsWith('-----BEGIN PUBLIC KEY-----') &&
    publicKey.indexOf('-----END PUBLIC KEY-----') !== -1 &&
    validator.isLength(publicKey, CONSTRAINTS_FIELDS.ACTORS.PUBLIC_KEY)
}
开发者ID:jiang263,项目名称:PeerTube,代码行数:7,代码来源:actor.ts

示例4: isActorPrivateKeyValid

function isActorPrivateKeyValid (privateKey: string) {
  return exists(privateKey) &&
    typeof privateKey === 'string' &&
    privateKey.startsWith('-----BEGIN RSA PRIVATE KEY-----') &&
    // Sometimes there is a \n at the end, so just assert the string contains the end mark
    privateKey.indexOf('-----END RSA PRIVATE KEY-----') !== -1 &&
    validator.isLength(privateKey, CONSTRAINTS_FIELDS.ACTORS.PRIVATE_KEY)
}
开发者ID:jiang263,项目名称:PeerTube,代码行数:8,代码来源:actor.ts

示例5: isValid

 public static isValid(obj: any): boolean {
     if (obj.post_id && !validator.isInt(obj.post_id))
         return false;
     if (!obj.post_date || !moment(obj.post_date, "MMM DD, YYYY").isValid())
         return false;
     if (!obj.post_status || !validator.isIn(obj.post_status, ["Enabled", "Disabled"]))
         return false;
     if (!obj.post_title || !validator.isLength(obj.post_title, {max: 255}))
         return false;
     if (!validator.isLength(obj.post_image, {max: 255}))
         return false;
     if (!validator.isLength(obj.post_intro_markdown, {max: 255}))
         return false;
     if (!obj.post_markdown || !validator.isLength(obj.post_markdown, {max: 10000}))
         return false;
     if (!obj.post_alias || !validator.isLength(obj.post_alias, {min: 5, max: 255}))
         return false;
     return true;
 }
开发者ID:nicholas-robson,项目名称:dkydev_webapp,代码行数:19,代码来源:post.ts

示例6: isActivityPubUrlValid

function isActivityPubUrlValid (url: string) {
  const isURLOptions = {
    require_host: true,
    require_tld: true,
    require_protocol: true,
    require_valid_protocol: true,
    protocols: [ 'http', 'https' ]
  }

  // We validate 'localhost', so we don't have the top level domain
  if (isTestInstance()) {
    isURLOptions.require_tld = false
  }

  return exists(url) && validator.isURL('' + url, isURLOptions) && validator.isLength('' + url, CONSTRAINTS_FIELDS.ACTORS.URL)
}
开发者ID:quoidautre,项目名称:PeerTube,代码行数:16,代码来源:misc.ts

示例7: isRemoteVideoUrlValid

function isRemoteVideoUrlValid (url: any) {
  return url.type === 'Link' &&
    (
      ACTIVITY_PUB.URL_MIME_TYPES.VIDEO.indexOf(url.mimeType) !== -1 &&
      isActivityPubUrlValid(url.href) &&
      validator.isInt(url.width + '', { min: 0 }) &&
      validator.isInt(url.size + '', { min: 0 })
    ) ||
    (
      ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.indexOf(url.mimeType) !== -1 &&
      isActivityPubUrlValid(url.href) &&
      validator.isInt(url.width + '', { min: 0 })
    ) ||
    (
      ACTIVITY_PUB.URL_MIME_TYPES.MAGNET.indexOf(url.mimeType) !== -1 &&
      validator.isLength(url.href, { min: 5 }) &&
      validator.isInt(url.width + '', { min: 0 })
    )
}
开发者ID:quoidautre,项目名称:PeerTube,代码行数:19,代码来源:videos.ts

示例8: isVideoLanguageValid

function isVideoLanguageValid (value: any) {
  return value === null ||
    (typeof value === 'string' && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.LANGUAGE))
}
开发者ID:jiang263,项目名称:PeerTube,代码行数:4,代码来源:videos.ts

示例9: isString

commentSchema.path('message').validate((msg: any) => {
	return isString(msg) && validator.isLength(msg, 3, 5000);
}, 'Message must be at least 3 chars and no longer than 5k characters.');
开发者ID:freezy,项目名称:node-vpdb,代码行数:3,代码来源:comment.schema.ts

示例10: isVideoFileInfoHashValid

function isVideoFileInfoHashValid (value: string) {
  return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH)
}
开发者ID:quoidautre,项目名称:PeerTube,代码行数:3,代码来源:videos.ts


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