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

TypeScript validator.isUUID函数代码示例

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

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



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

示例1: it

    it("should return valid append response", async () => {
      const insertResponse = await service.insert(input, ContentType.OCTETSTREAM, buffer);
      expect(validator.isUUID(insertResponse)).toBeTruthy();

      const resourceId = insertResponse;
      const appendedBuffer = await getFileBuffer("test.pdf");
      const appendResponse = await service.append(resourceId, input, ContentType.OCTETSTREAM, appendedBuffer);
      expect(appendResponse).toEqual(insertResponse);

      const ledgersResponse = await service.ledgers.get(resourceId);

      // Need to sort the tags array so matching will not fail on different ordering
      ledgersResponse.tags.sort();

      expect(ledgersResponse).toMatchObject({
        name: input.name,
        author_id: input.authorId,
        tags: input.tags,
        resource_id: resourceId,
        resource_address: expect.anything(),
        resource_size: expect.anything(),
        resource_content_type: ContentType.OCTETSTREAM,
        created_on: expect.anything(),
        deleted_on: "0001-01-01T00:00:00Z"
      });
    });
开发者ID:trussle,项目名称:snowy-js-client,代码行数:26,代码来源:snowy.spec.ts


示例2: disambiguatePipeline

export async function disambiguatePipeline(pipelineIDOrName: any, command: Command) {
  const headers = {Accept: 'application/vnd.heroku+json; version=3.pipelines'}

  if (isUUID(pipelineIDOrName)) {
    const {body: pipeline} = await command.heroku.get<Heroku.Pipeline>(`/pipelines/${pipelineIDOrName}`, {headers})
    return pipeline
  } else {
    const {body: pipelines} = await command.heroku.get<Heroku.Pipeline>(`/pipelines?eq[name]=${pipelineIDOrName}`, {headers})

    switch (pipelines.length) {
    case 0:
      command.error('Pipeline not found')
      break
    case 1:
      return pipelines[0]
    default:
      let choices = pipelines.map(function (x: Heroku.Pipeline) { return {name: new Date(x.created_at!), value: x} })
      let questions = [{
        type: 'list',
        name: 'pipeline',
        message: `Which ${pipelineIDOrName} pipeline?`,
        choices
      }]

      return prompt(questions)
    }
  }
}
开发者ID:jimmyurl,项目名称:cli,代码行数:28,代码来源:pipelines.ts


示例3: generateWatchHtmlPage

async function generateWatchHtmlPage (req: express.Request, res: express.Response, next: express.NextFunction) {
  const videoId = '' + req.params.id
  let videoPromise: Bluebird<VideoModel>

  // Let Angular application handle errors
  if (validator.isUUID(videoId, 4)) {
    videoPromise = VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(videoId)
  } else if (validator.isInt(videoId)) {
    videoPromise = VideoModel.loadAndPopulateAccountAndServerAndTags(+videoId)
  } else {
    return res.sendFile(getIndexPath(req))
  }

  let [ file, video ] = await Promise.all([
    readFileBufferPromise(getIndexPath(req)),
    videoPromise
  ])

  const html = file.toString()

  // Let Angular application handle errors
  if (!video || video.privacy === VideoPrivacy.PRIVATE) return res.sendFile(getIndexPath(req))

  const htmlStringPageWithTags = addOpenGraphAndOEmbedTags(html, video)
  res.set('Content-Type', 'text/html; charset=UTF-8').send(htmlStringPageWithTags)
}
开发者ID:jiang263,项目名称:PeerTube,代码行数:26,代码来源:client.ts


示例4: validateUUID

    @log
    validateUUID(req: Request, res: Response, next: NextFunction, id: any):
        void {
        if (!isUUID(id)) {
            logger.debug('status = 400');
            res.status(400).send(`${id} ist keine gueltige Buch-ID`);
            return;
        }

        next();
    }
开发者ID:AdrianFoell,项目名称:VP,代码行数:11,代码来源:request_handler.ts


示例5: Number

 Object.keys(modelIds).forEach((id) => {
   let _id = context.identifiers[first.identifier];
   if (modelIds[id] === 'INTEGER' && validator.isInt(String(_id))) {
     modelIds[id] = Number(_id);
   }
   else if (modelIds[id] === 'UUID' && validator.isUUID(String(_id))) {
     modelIds[id] = _id;
   }
   else if (modelIds[id] !== 'INTEGER' && modelIds[id] !== 'UUID') {
     modelIds[id] = String(_id);
   }
   else {
     delete modelIds[id];
   }
 });
开发者ID:repositive,项目名称:hapi-path-generator,代码行数:15,代码来源:queryGenerator.ts


示例6: it

    it("returns content with valid resource id", async () => {
      const buffer: Body = await getFileBuffer();
      const fileContents = buffer.toString();

      const content = await service.contents.post(ContentType.OCTETSTREAM, buffer);
      const ledger = generateLedgerFromContent(content);

      const ledgersResponse = await service.ledgers.post(ledger);
      expect(validator.isUUID(ledgersResponse)).toBeTruthy();

      const contentBuffer = await service.contents.get(ledgersResponse);

      const contentString = contentBuffer.toString();
      expect(contentString).toEqual(fileContents);
    });
开发者ID:trussle,项目名称:snowy-js-client,代码行数:15,代码来源:contents.spec.ts


示例7: it

  it("should return valid GET and POST responses", async () => {
      const ledger = generateLedger();
      const ledgersResponse = await service.ledgers.post(ledger);
      expect(validator.isUUID(ledgersResponse)).toBeTruthy();

      const resourceId = ledgersResponse;
      const response = await service.ledgers.get(resourceId);

      // Need to sort the tags array so matching will not fail on different ordering
      response.tags.sort();

      expect(response).toMatchObject({
        ...ledger,
        resource_id: resourceId,
        created_on: expect.anything(),
        deleted_on: "0001-01-01T00:00:00Z"
      });
  });
开发者ID:trussle,项目名称:snowy-js-client,代码行数:18,代码来源:ledgers.spec.ts


示例8:

  result = validator.isMongoId('sample');

  result = validator.isMultibyte('sample');

  result = validator.isNull('sample');

  result = validator.isNumeric('sample');

  result = validator.isSurrogatePair('sample');

  let isURLOptions: ValidatorJS.IsURLOptions;
  result = validator.isURL('sample');
  result = validator.isURL('sample', isURLOptions);

  result = validator.isUUID('sample');
  result = validator.isUUID('sample', 5);
  result = validator.isUUID('sample', 'all');

  result = validator.isUppercase('sample');

  result = validator.isVariableWidth('sample');

  result = validator.isWhitelisted('sample', 'abc');
  result = validator.isWhitelisted('sample', ['a', 'b', 'c']);

  result = validator.matches('foobar', 'foo/i');
  result = validator.matches('foobar', 'foo', 'i');
}

// **************
开发者ID:Crevil,项目名称:DefinitelyTyped,代码行数:30,代码来源:validator-tests.ts


示例9: isUUIDValid

function isUUIDValid (value: string) {
  return exists(value) && validator.isUUID('' + value, 4)
}
开发者ID:jiang263,项目名称:PeerTube,代码行数:3,代码来源:misc.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript validator.matches函数代码示例发布时间:2022-05-25
下一篇:
TypeScript validator.isURL函数代码示例发布时间: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