Iban validation for french clients desactivated
This commit is contained in:
parent
ddc6b9d77e
commit
97cbb4fb25
|
@ -40,12 +40,24 @@ module.exports = Self => {
|
|||
min: 3, max: 10
|
||||
});
|
||||
|
||||
var validateIban = require('../validations/validateIban');
|
||||
Self.validateBinded('iban', validateIban, {
|
||||
message: 'The IBAN does not have the correct format',
|
||||
allowNull: true, // FIXME: Ignored by loopback when it's false
|
||||
allowBlank: true
|
||||
Self.validateAsync('iban', ibanNeedsValidation, {
|
||||
message: 'The IBAN does not have the correct format'
|
||||
});
|
||||
var validateIban = require('../validations/validateIban');
|
||||
async function ibanNeedsValidation(err, done) {
|
||||
let filter = {
|
||||
fields: ['code'],
|
||||
where: {id: this.countryFk}
|
||||
};
|
||||
let country = await Self.app.models.Country.findOne(filter);
|
||||
let code = country ? country.code.toLowerCase() : null;
|
||||
if (code === 'fr')
|
||||
return done();
|
||||
|
||||
if (!validateIban(this.iban))
|
||||
err();
|
||||
done();
|
||||
}
|
||||
|
||||
Self.validateAsync('fi', tinIsValid, {
|
||||
message: 'Invalid TIN'
|
||||
|
|
Loading…
Reference in New Issue