Added forbidden argument names in accordance with constants
This commit is contained in:
parent
099e3b6951
commit
4e392a956b
@ -55,11 +55,11 @@
|
||||
class="tb-error">
|
||||
warning
|
||||
</mat-icon>
|
||||
} @else if (argumentFormGroup.get('argumentName').touched && argumentFormGroup.get('argumentName').hasError('equalCtx')) {
|
||||
} @else if (argumentFormGroup.get('argumentName').touched && argumentFormGroup.get('argumentName').hasError('forbiddenName')) {
|
||||
<mat-icon matSuffix
|
||||
matTooltipPosition="above"
|
||||
matTooltipClass="tb-error-tooltip"
|
||||
[matTooltip]="'calculated-fields.hint.argument-name-ctx' | translate"
|
||||
[matTooltip]="'calculated-fields.hint.argument-name-forbidden' | translate"
|
||||
class="tb-error">
|
||||
warning
|
||||
</mat-icon>
|
||||
|
||||
@ -67,7 +67,7 @@ export class CalculatedFieldArgumentPanelComponent implements OnInit, AfterViewI
|
||||
readonly defaultLimit = Math.floor(this.maxDataPointsPerRollingArg / 10);
|
||||
|
||||
argumentFormGroup = this.fb.group({
|
||||
argumentName: ['', [Validators.required, this.uniqNameRequired(), this.notEqualCtxValidator(), Validators.pattern(charsWithNumRegex), Validators.maxLength(255)]],
|
||||
argumentName: ['', [Validators.required, this.uniqNameRequired(), this.forbiddenArgumentNameValidator(), Validators.pattern(charsWithNumRegex), Validators.maxLength(255)]],
|
||||
refEntityId: this.fb.group({
|
||||
entityType: [ArgumentEntityType.Current],
|
||||
id: ['']
|
||||
@ -254,10 +254,11 @@ export class CalculatedFieldArgumentPanelComponent implements OnInit, AfterViewI
|
||||
}
|
||||
}
|
||||
|
||||
private notEqualCtxValidator(): ValidatorFn {
|
||||
private forbiddenArgumentNameValidator(): ValidatorFn {
|
||||
return (control: FormControl) => {
|
||||
const trimmedValue = control.value.trim().toLowerCase();
|
||||
return trimmedValue === 'ctx' ? { equalCtx: true } : null;
|
||||
const forbiddenArgumentNames = ['ctx', 'e', 'pi'];
|
||||
return forbiddenArgumentNames.includes(trimmedValue) ? { forbiddenName: true } : null;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -1069,7 +1069,7 @@
|
||||
"argument-name-pattern": "Argument name is invalid.",
|
||||
"argument-name-duplicate": "Argument with such name already exists.",
|
||||
"argument-name-max-length": "Argument name should be less than 256 characters.",
|
||||
"argument-name-ctx": "Argument name 'ctx' is reserved and cannot be used.",
|
||||
"argument-name-forbidden": "Argument name is reserved and cannot be used.",
|
||||
"argument-type-required": "Argument type is required.",
|
||||
"max-args": "Maximum number of arguments reached.",
|
||||
"decimals-range": "Decimals by default should be a number between 0 and 15.",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user