JSON模式validationaws lambda
我需要validation我的aws lambda事件模式。 我用vandium进行validation。 我有两个不同的情况。
- lambda函数仅支持一种types的事件。
喜欢这个
var vandium = require('vandium'); vandium.validation({ name: vandium.types.string().required() }); exports.handler = vandium(function (event, context, callback) { console.log('hello: ' + event.name); callback(null, 'Hello from Lambda'); });
在这种情况下,只有密钥存在或不存在时, vandium才会生效。 但我需要检查是否有任何额外的密钥存在或不。
- lambda函数支持多种types的事件。
喜欢这个
var vandium = require('vandium'); vandium.validation({ operation: vandium.types.string().required(), name: vandium.types.string().required(), }); exports.handler = vandium(function (event, context, callback) { const operation = event.operation; switch (operation) { case 'test1': test1(event); break; case 'test2': test2(event); break; default: callback(new Error("Unrecognized operation=" + operation)); break; } function test1(event) { //console.log('hello: ' + event.name); callback(null, 'Hello from Lambda'); } function test2(event) { //console.log('hello: ' + event.name); callback(null, 'Hello from Lambda'); } });
在这种情况下,test1&test2的事件是不同的。 喜欢这个
test1 {“name”:“hello”,“id”:100}
test2 {“schoolName”:“threni”,“teacher”:“abcd”}
- 哪一个是这样的问题最好的scemavalidationnpm包?
- vandium适合jsonvalidation。
你有没有看过ajv ? 像使用JSON模式validation数据一样
- AWS EB实例是否在崩溃时自动重启?
- 如何为Node.js WebSocket服务器configurationAWS Elastic Beanstalk?
- 将rds上的postgresql连接到节点js服务器
- 节点expressionaws s3.listBuckets在页面呈现后执行callback
- 用于Amazon SES的Node.js模块
- 如何在输出lambda函数url中replace'latest'? 我怎么能做我自己的资源?
- 如何在AWS API网关中debugging“Missing Authentication Token”?
- 自定义AWS ElasticBean NodeJS安装(使用纱线)
- 从节点中的mongodb中排除kerberos依赖