vo.getResultFun()
and cod
returns 'G'
Java validation
JavaScript
x
5
1
if ( genericValidator.isBlankOrNull(vo.getResultFun()) ||
2
!("G".equalsIgnoreCase(vo.getResultFun()) || "B".equalsIgnoreCase(vo.getResultFun()))) {
3
throw new UCNaoCadastradaGerBenException();
4
}
5
NodeJS
JavaScript
1
4
1
if (Validator.isNullUndefinedEmpty(cod) ||
2
!(Validator.isEqual(cod, 'B', true) || Validator.isEqual(cod, 'G', true))) {
3
callback(Translate.__('K1.CH1', lang), null);
4
isEqual
JavaScript
1
16
16
1
static isEqual(str1: string, str2: string, ignoreCase: boolean = false): boolean {
2
let ret = false;
3
if (ignoreCase) {
4
ret =
5
(str1 === undefined && str2 === undefined) ||
6
(str1 === null && str2 === null) ||
7
(str1 != null && str2 != null && typeof str1 === 'string' && typeof str2 === 'string' && str1.toUpperCase() === str2.toUpperCase());
8
} else {
9
ret =
10
(str1 === undefined && str2 === undefined) ||
11
(str1 === null && str2 === null) ||
12
(str1 != null && str2 != null && typeof str1 === 'string' && typeof str2 === 'string' && str1 === str2);
13
}
14
return ret;
15
}
16
Why NodeJS return the callback and Java don’t throws the exception?
Advertisement
Answer
The result of this js part :
JavaScript
1
2
1
!(Validator.isEqual(cod, 'B', true) || Validator.isEqual(cod, 'G', true))
2
is false
as the result of this java part:
JavaScript
1
2
1
!("G".equalsIgnoreCase(vo.getResultFun()) || "B".equalsIgnoreCase(vo.getResultFun()))
2
So there are several options :
Validator.isNullUndefinedEmpty
doesn’t workscod
is not strictly equals to ‘G’- The callback function is not called