title: express-validator custom validator pass but not return request
body: <p>I'm trying to create a custom validator to create a generic enum validator, but when my rule passes to test, the request does not return it's as if nextFunction didn't trigger. When my rule fails custom validation returns with success.</p>
  <p>*what i mean is that when the validation is correct it creates an infinite loop...</p>
  <p>My custom validator:</p>
  <pre><code>import { CustomValidator, Meta } from &quot;express-validator&quot;;
  
  export class EnumMapper&lt;T extends { [name: string]: any }&gt; {
  
      constructor(public enumObject: T) { }
  }
  export const isInEnum: CustomValidator = P =&gt; (value: any) =&gt; {
      let genericEnum = new EnumMapper(P);
      return Object.values(genericEnum.enumObject).includes(value);
  };
  </code></pre>
  <p>how am i using my custom validator in code:</p>
  <pre><code>export const createOfficeHoursValidation = [
      body('type').custom(isInEnum(OfficeHoursType, body.prototype)),
      // of this the meta-object is required.
      // using body.prototype is having the same effect as creating a {location, path and req} object 
      ...
  ]
  </code></pre>
  <p>any way to solve this problem?
  I googled and saw some solutions to validate enums, but not in a generic way..</p>