dev #1731

Merged
jgallego merged 105 commits from dev into test 2023-08-31 09:13:29 +00:00
3 changed files with 40 additions and 10 deletions
Showing only changes of commit f54a239229 - Show all commits

View File

@ -1,21 +1,45 @@
const validateIban = require('../validateIban');
describe('IBAN validation', () => {
it('should return false for non-IBAN input', () => {
let isValid = validateIban('Pepinillos');
it('should return false for invalid Spanish IBAN format', () => {
let isValid = validateIban('ES00 9999 0000 9999 0000 9999', 'ES');
expect(isValid).toBeFalsy();
});
it('should return false for invalid spanish IBAN input', () => {
let isValid = validateIban('ES00 9999 0000 9999 0000 9999');
expect(isValid).toBeFalsy();
});
it('should return true for valid spanish IBAN', () => {
let isValid = validateIban('ES91 2100 0418 4502 0005 1332');
it('should return true for valid Spanish IBAN', () => {
let isValid = validateIban('ES91 2100 0418 4502 0005 1332', 'ES');
expect(isValid).toBeTruthy();
});
it('should return false for invalid Spanish IBAN with incorrect length', () => {
let isValid = validateIban('ES91210004184502000513', 'ES');
expect(isValid).toBeFalsy();
});
it('should return false for invalid Spanish IBAN with incorrect module97 result', () => {
let isValid = validateIban('ES9121000418450200051331', 'ES');
expect(isValid).toBeFalsy();
});
it('should return true for a non-Spanish countryCode', () => {
let isValid = validateIban('DE89370400440532013000', 'AT');
expect(isValid).toBeTruthy();
});
it('should return true for null IBAN', () => {
let isValid = validateIban(null, 'ES');
expect(isValid).toBeTruthy();
});
it('should return false for non-string IBAN', () => {
let isValid = validateIban(12345, 'ES');
expect(isValid).toBeFalsy();
});
});

View File

@ -90,6 +90,9 @@ module.exports = Self => {
});
async function ibanNeedsValidation(err, done) {
if (!this.bankEntityFk)
return done();
const bankEntity = await Self.app.models.BankEntity.findById(this.bankEntityFk);
const filter = {
fields: ['code'],

View File

@ -7,6 +7,9 @@ module.exports = Self => {
});
async function ibanValidation(err, done) {
if (!this.bankEntityFk)
return done();
const bankEntity = await Self.app.models.BankEntity.findById(this.bankEntityFk);
const filter = {
fields: ['code'],