本文整理汇总了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"
});
});
示例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)
}
}
}
示例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)
}
示例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();
}
示例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];
}
});
示例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);
});
示例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"
});
});
示例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');
}
// **************
示例9: isUUIDValid
function isUUIDValid (value: string) {
return exists(value) && validator.isUUID('' + value, 4)
}