This commit is contained in:
Josh Harvey 2018-05-01 19:35:54 +03:00
parent f7561acf3c
commit 80e851fb59
9 changed files with 131 additions and 76 deletions

23
lib/compliance.js Normal file
View file

@ -0,0 +1,23 @@
const _ = require('lodash/fp')
const ofac = require('./ofac/index')
function matchOfac (customer) {
const nameParts = _.flatMap(_.split(/\s+/), [customer.firstName, customer.lastName])
const birthDate = customer.dateOfBirth
const result = ofac.match(nameParts, birthDate)
console.log('DEBUG200: %s', result)
if (result > 0.8) throw new Error('Compliance error')
}
function validateCustomer (config, customer) {
if (config.sanctionsVerificationActive) {
matchOfac(customer)
}
return customer
}
module.exports = {validateCustomer}