diff options
author | 2023-06-14 15:33:18 +0100 | |
---|---|---|
committer | 2023-06-19 22:44:26 +0000 | |
commit | 068a01213a8b2daac93b0c2aab33b9a73e7fb70b (patch) | |
tree | aa3ef3e0ed773a0e0a3d7d6f989aa6583e75e24d /catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts | |
parent | 4898da84c488cd51f872be95be5512f1fc6273a3 (diff) |
No error on invalid index
Issue-ID: SDC-4534
Signed-off-by: shikha0203 <shivani.khare@est.tech>
Change-Id: I7df59d0b8a362d15d54d1a6b862201fd0caf1e31
Diffstat (limited to 'catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts')
-rw-r--r-- | catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts index 26098b7020..a1ed8aa137 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts @@ -229,7 +229,7 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges { const selectedProperty: PropertyDropdownValue = this.formGroup.value.selectedProperty; if (selectedProperty != null && selectedProperty.isList && formGroupStatus && this.indexListValues.length > 0) { this.indexListValues.forEach((indexObject : ToscaIndexObject, index) => { - if (indexObject.indexValue == null) { + if (indexObject.indexValue == '') { formGroupStatus = false; return; } @@ -617,17 +617,23 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges { } indexTokenChange(indexObject : ToscaIndexObject): void { - if ((indexObject.indexValue).toLowerCase() === 'index') { + if ((indexObject.indexValue).toLowerCase() === 'index' ) { this.formValidation(); - return; } - let indexTokenValue = Number(indexObject.indexValue); - if (isNaN(indexTokenValue)) { - indexObject.indexValue = "0"; + + const regEx = /^[0-9]*$/; + const error = document.getElementById('error'); + + if (!(regEx.test(indexObject.indexValue)) && (indexObject.indexValue).toLowerCase() !== 'index') { + error.textContent='Invalid value - must be an integer or INDEX'; + this.onValidityChange.emit({ + isValid: false, + toscaGetFunction: this.formGroup.valid ? this.buildGetFunctionFromForm() : undefined + }); + } else { + error.textContent=''; this.formValidation(); - return; } - this.formValidation(); } showPropertySourceDropdown(): boolean { @@ -646,6 +652,9 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges { return this.formGroup.get('selectedProperty') as FormControl; } + onChangeIndexValue(index: ToscaIndexObject, value: any) { + this.indexTokenChange(index); + } } export interface PropertyDropdownValue { |