title: Validating req.params with express validator
body: <p>I want the user to be able to write a specific account number in the endpoint, been trying to validate the endpoint param if it exists in my database. I couldn't get it to work, please what am I doing wrong?</p>
  
  <blockquote>
    <p>My validation</p>
  </blockquote>
  
  <pre><code>const validateReq: [
  param('accountNumber').exists().custom(acctNo =&gt; accountNumberExist(acctNo)),]
  </code></pre>
  
  <blockquote>
    <p>My accountNumberExist function</p>
  </blockquote>
  
  <pre><code>    accountNumberExist(inputAcct) {
      const isfound = accounts.find(account =&gt; account.accountNumber === inputAcct);
      if (isfound === undefined) throw new Error('Account Number not found');
    }
  </code></pre>
  
  <blockquote>
    <p>My accounts file</p>
  </blockquote>
  
  <pre><code>    const accounts = [
    {
      id: 1,
      accountNumber: 1234567890,
      createdOn: new Date(),
      owner: 1,
      type: 'current',
      balance: 23444.43,
      status: 'active',
    },
    {
      id: 2,
      accountNumber: 1234167890,
      createdOn: new Date(),
      owner: 1,
      type: 'savings',
      balance: 2233444.43,
      status: 'active',
    },
    {
      id: 3,
      accountNumber: 9987654321,
      createdOn: new Date(),
      owner: 2,
      type: 'saving',
      balance: 73444.43,
      status: 'active',
    },
  ];
  </code></pre>
  
  <p>But this is always throwing the 'Account Number not found' error even though, the req.param exists in my accounts database.</p>