Open batpad opened 6 years ago
This looks maybe decent: https://booker.codes/input-validation-in-express-with-express-validator/
And for validation things that are being saved to the model, we should be able to define the validators we need on the model definition itself, as per http://docs.sequelizejs.com/manual/tutorial/models-definition.html#validations -- and then ideally be able to catch the ValidationError
raised and return the response to the user.
Right now, we're doing validation inside each end-point where we expect data.
A lot of the validation rules are similar across end-points. We should use a library or a mechanism to reduce a lot of the validation logic in individual end-points and delegate to a validation module.
Not urgent at all, just wanted to ticket - if I stumble across any libraries that seem good for this, will drop into this ticket.
cc @emilymdubois