diff options
Diffstat (limited to 'usecaseui-portal/src/app/shared/utils')
-rw-r--r-- | usecaseui-portal/src/app/shared/utils/utils.ts | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/usecaseui-portal/src/app/shared/utils/utils.ts b/usecaseui-portal/src/app/shared/utils/utils.ts index 1aa9673e..63d3e3b7 100644 --- a/usecaseui-portal/src/app/shared/utils/utils.ts +++ b/usecaseui-portal/src/app/shared/utils/utils.ts @@ -31,4 +31,46 @@ export class Util { let formattime = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds; return formattime; } + + getRulesText(words: string, title: string, index: number, rulesText: any[]){ + return rulesText[index] = words + title + }; + validator(title: string, key: string, val: any, index: number, rulesText: any[], validateRulesShow: any[]) { + let maxNumberReg = /^([1-9]\d{0,4}|100000)$/, // Check integer between 1 ~ 100000 + expDataRateReg = /^([1-9]\d{2}|[1-3]\d{3}|3000)$/, // Check integer between 100 ~ 3000 + latencyReg = /^1[0-9]$|^[2-9]\d$|^1\d{2}$|^200$/; // Check integers between 10 and 200 + if (val === null || val.replace(/\s*/g, '').length <= 0) { + validateRulesShow[index] = true; + this.getRulesText('Please enter ', title, index,rulesText); + return false + } else { + validateRulesShow[index] = false; + } + if (isNaN(val) && (key === 'maxNumberofUEs' || key === 'expDataRateDL' || key === 'expDataRateUL' || key === 'latency')) { + validateRulesShow[index] = true; + this.getRulesText('Only numbers can be entered', '', index,rulesText); + return false + } + if (!isNaN(val) && key === 'maxNumberofUEs' && !maxNumberReg.test(val)) { + validateRulesShow[index] = true; + this.getRulesText('Scope: 1-100000', '', index,rulesText); + return false + } else { + validateRulesShow[index] = false; + } + if ( !isNaN(val) && (key === 'expDataRateDL' || key === 'expDataRateUL') && !expDataRateReg.test(val)) { + validateRulesShow[index] = true; + this.getRulesText('Scope: 100-3000', '', index,rulesText); + return false + } else { + validateRulesShow[index] = false; + } + if (!isNaN(val) && key === 'latency' && !latencyReg.test(val)) { + validateRulesShow[index] = true; + this.getRulesText('Scope: 10-200', '', index,rulesText); + return false + } else { + validateRulesShow[index] = false; + } + } }
\ No newline at end of file |