Bug with empty value validations fixed
This commit is contained in:
parent
4eebdf96ee
commit
8ee649b9d0
|
@ -72,9 +72,11 @@ export function validateAll(value, validations) {
|
|||
export function validate(value, conf) {
|
||||
let validator = validators[conf.validation];
|
||||
try {
|
||||
checkNull(value, conf);
|
||||
let isEmpty = value == null || value === '';
|
||||
|
||||
if (validator) // && value != null ??
|
||||
if (isEmpty)
|
||||
checkNull(value, conf);
|
||||
if (validator && (!isEmpty || conf.validation == 'presence'))
|
||||
validator(value, conf);
|
||||
} catch (e) {
|
||||
let message = conf.message ? conf.message : e.message;
|
||||
|
|
|
@ -43,7 +43,9 @@ module.exports = function(Self) {
|
|||
|
||||
var validateIban = require('../validations/validateIban');
|
||||
Self.validateBinded('iban', validateIban, {
|
||||
message: 'El iban no tiene el formato correcto'
|
||||
message: 'El iban no tiene el formato correcto',
|
||||
allowNull: true, // FIXME: Ignored by loopback when it's false
|
||||
allowBlank: true
|
||||
});
|
||||
|
||||
let validateDni = require('../validations/validateDni');
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module.exports = fiWithCountry => {
|
||||
if (fiWithCountry == null)
|
||||
return true;
|
||||
module.exports = function(fiWithCountry) {
|
||||
if (fiWithCountry == null) return true;
|
||||
if (typeof fiWithCountry != 'string') return false;
|
||||
|
||||
fiWithCountry = fiWithCountry.toUpperCase();
|
||||
|
||||
|
|
Loading…
Reference in New Issue