Open TimSpeelman opened 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.
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 thatValidator.validate(data)
returns a boolean andValidator.errors()
returns thestring[]
of error messages. What do you think?