refactor: simplyfy conditions
This commit is contained in:
parent
721ef09dad
commit
8bca10bcc0
1 changed files with 3 additions and 9 deletions
|
|
@ -1450,18 +1450,12 @@ Object.assign(frappe.utils, {
|
|||
*/
|
||||
|
||||
// return empty for null, undefined, or empty string
|
||||
if (number == null || number === "") {
|
||||
if (!number || isNaN(number)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// extract digits from the number
|
||||
const digits = String(number).match(/\d/g);
|
||||
if (!digits) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// return number if total digits are less than min_length
|
||||
const len = digits.length;
|
||||
// return number if total digits is lesser than min_length
|
||||
const len = String(number).match(/\d/g)?.length || 0;
|
||||
if (len < min_length) {
|
||||
return number.toString();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue