TimSpeelman / in4392-lab

0 stars 1 forks source link

Proper Param and Payload Validation #46

Open TimSpeelman opened 6 years ago

TimSpeelman commented 6 years ago

What do you mean by 'the params object'? I propose to merge the rules and validator of each Lambda handler into a specific class, e.g. DaemonValidator, ProcessStepOneValidator, ApiValidator and slightly change the interface such that Validator.validate(data) returns a boolean and Validator.errors() returns the string[] of error messages. What do you think?

PhilipeLouchtch commented 6 years ago

What do you mean by 'the params object'? I propose to merge the rules and validator of each Lambda handler into a specific class, e.g. DaemonValidator, ProcessStepOneValidator, ApiValidator and slightly change the interface such that Validator.validate(data) returns a boolean and Validator.errors() returns the string[] of error messages. What do you think?

I meant, now the validation is outside the object that should be valid. My proposal was to use the object validator within the object that should be valid (constructor). It's the idea that once an object is created, it is valid. Otherwise, it cannot be created successfully.