Skip to content

Commit

Permalink
fix: bic validation with iban_path
Browse files Browse the repository at this point in the history
  • Loading branch information
OxCom committed Sep 13, 2020
1 parent 931e3ab commit 3269cec
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Constraints/Bic.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default class Bic extends AbstractConstraint {

if (this.options.iban_path !== null && isString(this.options.iban_path)) {
// we assume that we have valid IBAN
const iban = options.form[this.options.iban_path];
const iban = options.form.data[this.options.iban_path];

if (this.isEmptyValue(iban)) {
return;
Expand Down
4 changes: 2 additions & 2 deletions tests/Constraints/Bic.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('Bic', function () {
{bic:'BARCVGSA', iban: 'GB12 CPBK 0892 9965 0449 911'},
]
.forEach((pair) => {
const e = object.validate(pair.bic, {form: {my_awesome_iban: pair.iban}});
const e = object.validate(pair.bic, {form: {data: {my_awesome_iban: pair.iban}}});

assert.ok(typeof e === 'undefined', e);
});
Expand All @@ -102,7 +102,7 @@ describe('Bic', function () {
it('is invalid: with IBAN', function () {
let object = new Bic({iban_path: 'my_awesome_iban'});

const options = {form: {my_awesome_iban: 'FR14 2004 1010 0505 0001 3M02 606'}};
const options = {form: {data: {my_awesome_iban: 'FR14 2004 1010 0505 0001 3M02 606'}}};
const e = object.validate('UNCRIT2B912', options);

assert.strictEqual(e.message, 'This Business Identifier Code (BIC) is not associated with IBAN FR14 2004 1010 0505 0001 3M02 606.');
Expand Down

0 comments on commit 3269cec

Please sign in to comment.