node.jshelperscaffoldingrailway.jscompoundjs

Helper in NodeJS+CompoundJS


I'm just starting out in CompoundJs and there's a lot I still need to learn.

I'm just trying to figure out how Helpers work in NodeJS+CompoundJS, from what I've seen so far Helpers are intended to be used with Views and not so much with your Controllers. However I would like to make a simple function that will validate the user input given in params (check if certain params are defined and optionally check if their value is valid). Can anyone explain to me what would be the best way of implementing this? Keeping in mind that I will want to use this in many different controllers so it should be globally available. Do i have to use custom validator or helper?


Solution

  • Validation is probably better suited for the model. You could also do lower-level validation in the controller. The helpers are just designed for exposing global variables to the view templates.