當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。