From 2ece50e03b9ce78fc1be5c47671513b7430cadda Mon Sep 17 00:00:00 2001 From: Maksym Tsymbarov Date: Wed, 4 Mar 2026 14:24:46 +0100 Subject: [PATCH] Fixed CF name validation --- .../dialog/calculated-field-dialog.component.html | 6 ------ .../dialog/calculated-field-dialog.component.ts | 8 ++++---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.html b/ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.html index f5f009b320..38c6991c1f 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.html @@ -38,8 +38,6 @@ @if (fieldFormGroup.get('name').hasError('required')) { {{ 'common.hint.title-required' | translate }} - } @else if (fieldFormGroup.get('name').hasError('pattern')) { - {{ 'common.hint.title-pattern' | translate }} } @else if (fieldFormGroup.get('name').hasError('maxlength')) { {{ 'common.hint.title-max-length' | translate }} } @@ -89,8 +87,6 @@ @if (configFormGroup.get('expressionSIMPLE').hasError('required')) { {{ 'calculated-fields.hint.expression-required' | translate }} - } @else if (configFormGroup.get('expressionSIMPLE').hasError('pattern')) { - {{ 'calculated-fields.hint.expression-invalid' | translate }} } @else if (configFormGroup.get('expressionSIMPLE').hasError('maxLength')) { {{ 'calculated-fields.hint.expression-max-length' | translate }} } @@ -173,8 +169,6 @@ @if (outputFormGroup.get('name').hasError('required')) { {{ 'common.hint.key-required' | translate }} - } @else if (outputFormGroup.get('name').hasError('pattern')) { - {{ 'common.hint.key-pattern' | translate }} } @else if (outputFormGroup.get('name').hasError('maxlength')) { {{ 'common.hint.key-max-length' | translate }} } diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.ts b/ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.ts index 5a4cc6cedb..3dcc759fc4 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.ts @@ -33,7 +33,7 @@ import { OutputType, OutputTypeTranslations } from '@shared/models/calculated-field.models'; -import { digitsRegex, oneSpaceInsideRegex } from '@shared/models/regex.constants'; +import { digitsRegex } from '@shared/models/regex.constants'; import { AttributeScope } from '@shared/models/telemetry/telemetry.models'; import { EntityType } from '@shared/models/entity-type.models'; import { map, startWith, switchMap } from 'rxjs/operators'; @@ -65,15 +65,15 @@ export interface CalculatedFieldDialogData { export class CalculatedFieldDialogComponent extends DialogComponent { fieldFormGroup = this.fb.group({ - name: ['', [Validators.required, Validators.pattern(oneSpaceInsideRegex), Validators.maxLength(255)]], + name: ['', [Validators.required, Validators.maxLength(255)]], type: [CalculatedFieldType.SIMPLE], debugSettings: [], configuration: this.fb.group({ arguments: this.fb.control({}), - expressionSIMPLE: ['', [Validators.required, Validators.pattern(oneSpaceInsideRegex), Validators.maxLength(255)]], + expressionSIMPLE: ['', [Validators.required, Validators.maxLength(255)]], expressionSCRIPT: [calculatedFieldDefaultScript], output: this.fb.group({ - name: ['', [Validators.required, Validators.pattern(oneSpaceInsideRegex), Validators.maxLength(255)]], + name: ['', [Validators.required, Validators.maxLength(255)]], scope: [{ value: AttributeScope.SERVER_SCOPE, disabled: true }], type: [OutputType.Timeseries], decimalsByDefault: [null as number, [Validators.min(0), Validators.max(15), Validators.pattern(digitsRegex)]],