Closed nelsonic closed 8 years ago
@nelsonic Initially we used tv4
directly in index.handler. So it looked like this:
import tv4 from 'tv4';
exports.handler = (event, context) => {
const validation = tv4.validateResult(event, payloadSchema, true);
if (!validation.valid) context.fail(validation.error);
...
For worse clear code syntax we did it as a callback and moved it to the lib
folder (later the getEnvironment function was added to lib
folder too). But I can't say why we are moved it to aws-lambda-helper.
I think we should remove validateWithSchema method that require tv4 at all from helper. It was my idea, in order to create validation wrapper, but I realize that I was wrong Validation used not often , not need to put it here, just use inside services directly use tv4.
@lilutanya thanks for confirming that. :+1:
this has been removed in the latest version. https://github.com/numo-labs/aws-lambda-helper/blob/7c1f5d64155795b7975d340ae8dd81e2b1e134c9/lib/index.js
@plaenen has deemed that including
tv4
in this module is not required as code required to use the method is roughly the same as simply callingtv4.validateResult
... @lilutanya do you remember what the original reason for including it was?