numo-labs / aws-lambda-helper

:lollipop: Collection of helper methods for lambda
GNU General Public License v3.0
22 stars 2 forks source link

Where are we using the validateWithSchema method? #3

Closed nelsonic closed 8 years ago

nelsonic commented 8 years ago

@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 calling tv4.validateResult... @lilutanya do you remember what the original reason for including it was?

s-voloshynenko commented 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.

lilutanya commented 8 years ago

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.

nelsonic commented 8 years ago

@lilutanya thanks for confirming that. :+1:

nelsonic commented 8 years ago

this has been removed in the latest version. https://github.com/numo-labs/aws-lambda-helper/blob/7c1f5d64155795b7975d340ae8dd81e2b1e134c9/lib/index.js