summaryrefslogtreecommitdiffhomepage
path: root/app/lib/formatters.js
blob: c5357cabd9147646b081076b7ce7c2b1212bc3bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import assert from 'assert';

/**
 * Format account number
 * @param {string} val  account number 
 */
export const formatAccount = (val) => {
  assert(typeof(val) === 'string');
  
  // display number altogether when longer than 12
  if(val.length > 12) {
    return val;
  }

  // display quartets
  return val.replace(/([0-9]{4})/g, '$1 ').trim();
};