Validating package payload Casual cam sites
Let us know in the comments or on twitter @futurestud_io. Futureflix is your own Netflix-like streaming platform and the app you’re building throughout the learn hapi learning path.
The very first approach assumes we leverage intermediate layer just after routing (sometimes even within a router) and before a controller to provide specific validations.Within last week’s tutorial you’ve learned how to access the request payload in hapi.Because you should never, ever trust provided data submitted by users, a common process is to validate the request payload against a given rule set.Technical details may depend on used framework and libraries but the idea is check payload correctness before it actually hits our business logic. The entire concept is all about performing validations like checking types, formats, lengths and requirements the soonest as it’s possible.Let’s see how it could look like with option which is supposed to be an array of all required URL query params.