json schema validation on aws lambda
<p>i need to validate my aws lambda event schema. i used <strong><em>vandium</em></strong> for validation. i have two diffrent cases.</p>

<ol>
<li>lambda function support only one type of event. </li>
</ol>

<p>like this</p>

<pre><code>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');
});
</code></pre>

<p>in this case, <strong><em>vandium</em></strong> only validate , if key is present or not. But i need to check if any extra key is present or not.</p>

<ol start="2">
<li>lambda function support multiple type of events. </li>
</ol>

<p>like this</p>

<pre><code>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');
    }

});
</code></pre>

<p>in this case, events for test1 &amp; test2 are diffrent. like this</p>

<blockquote>
  <p>test1{"name":"hello","id":100 }</p>
  
  <p>test2{"schoolName":"threni","teacher":"abcd" }</p>
</blockquote>

<ol>
<li>Which is the best scema validation npm package for problem like
this? </li>
<li>is <strong><em>vandium</em></strong> is suitable for json validation.?</li>
</ol>