Defining the isRealString function

In order to set up this validation, which we're going to be doing in other places too like createMessage, we're going to create a separate utils file. In here, I'm going to call this validation.js and this is where we can put some validators that we're going to need throughout the project.

In this section we're going to create one called isRealString. This is going to verify that a value is of a type string and that it's not just a bunch of spaces; it actually has real characters inside it. We're going to set this equal to a function that takes a string. This is going to be the string we validate, and it's actually not going to be terribly difficult. We're going to return and we're going to return the following ...

Get Advanced Node.js Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.