diff --git a/modules/ui/src/app/pages/devices/components/device-form/device-form.component.html b/modules/ui/src/app/pages/devices/components/device-form/device-form.component.html index 11f87ff33..5978f6d22 100644 --- a/modules/ui/src/app/pages/devices/components/device-form/device-form.component.html +++ b/modules/ui/src/app/pages/devices/components/device-form/device-form.component.html @@ -31,7 +31,7 @@ role="alert" aria-live="assertive"> Please, check. The manufacturer name must be a maximum of 64 + >Please, check. The manufacturer name must be a maximum of 28 characters. Only letters, numbers, and accented letters are permitted. @@ -49,7 +49,7 @@ role="alert" aria-live="assertive"> Please, check. The device model name must be a maximum of 64 + >Please, check. The device model name must be a maximum of 28 characters. Only letters, numbers, and accented letters are permitted. diff --git a/modules/ui/src/app/pages/devices/components/device-form/device-form.component.spec.ts b/modules/ui/src/app/pages/devices/components/device-form/device-form.component.spec.ts index 4ffbb402e..6ea72aa52 100644 --- a/modules/ui/src/app/pages/devices/components/device-form/device-form.component.spec.ts +++ b/modules/ui/src/app/pages/devices/components/device-form/device-form.component.spec.ts @@ -240,7 +240,7 @@ describe('DeviceFormComponent', () => { expect(error).toBeTruthy(); expect(modelError).toContain( - 'The device model name must be a maximum of 64 characters. Only letters, numbers, and accented letters are permitted.' + 'The device model name must be a maximum of 28 characters. Only letters, numbers, and accented letters are permitted.' ); }); }); @@ -283,7 +283,7 @@ describe('DeviceFormComponent', () => { expect(error).toBeTruthy(); expect(manufacturerError).toContain( - 'The manufacturer name must be a maximum of 64 characters. Only letters, numbers, and accented letters are permitted.' + 'The manufacturer name must be a maximum of 28 characters. Only letters, numbers, and accented letters are permitted.' ); }); }); diff --git a/modules/ui/src/app/pages/devices/components/device-form/device.validators.ts b/modules/ui/src/app/pages/devices/components/device-form/device.validators.ts index 5e54e7996..2b7b23ae1 100644 --- a/modules/ui/src/app/pages/devices/components/device-form/device.validators.ts +++ b/modules/ui/src/app/pages/devices/components/device-form/device.validators.ts @@ -23,15 +23,28 @@ import { Device } from '../../../../model/device'; */ export class DeviceValidators { readonly STRING_FORMAT_REGEXP = new RegExp( + "^([a-z0-9\\p{L}\\p{M}.',-_ ]{1,28})$", + 'u' + ); + + readonly FIRMWARE_FORMAT_REGEXP = new RegExp( "^([a-z0-9\\p{L}\\p{M}.',-_ ]{1,64})$", 'u' ); public deviceStringFormat(): ValidatorFn { + return this.stringFormat(this.STRING_FORMAT_REGEXP); + } + + public firmwareStringFormat(): ValidatorFn { + return this.stringFormat(this.FIRMWARE_FORMAT_REGEXP); + } + + private stringFormat(regExp: RegExp): ValidatorFn { return (control: AbstractControl): ValidationErrors | null => { const value = control.value?.trim(); if (value) { - const result = this.STRING_FORMAT_REGEXP.test(value); + const result = regExp.test(value); return !result ? { invalid_format: true } : null; } return null; diff --git a/modules/ui/src/app/pages/reports/components/filter-dialog/filter-dialog.component.ts b/modules/ui/src/app/pages/reports/components/filter-dialog/filter-dialog.component.ts index f8fea286b..3d8ac231a 100644 --- a/modules/ui/src/app/pages/reports/components/filter-dialog/filter-dialog.component.ts +++ b/modules/ui/src/app/pages/reports/components/filter-dialog/filter-dialog.component.ts @@ -162,7 +162,7 @@ export class FilterDialogComponent private createFilterForm() { this.filterForm = this.fb.group({ deviceInfo: ['', [this.deviceValidators.deviceStringFormat()]], - deviceFirmware: ['', [this.deviceValidators.deviceStringFormat()]], + deviceFirmware: ['', [this.deviceValidators.firmwareStringFormat()]], results: new FormArray(this.resultList.map(() => new FormControl(false))), }); } diff --git a/modules/ui/src/app/pages/testrun/components/progress-initiate-form/progress-initiate-form.component.ts b/modules/ui/src/app/pages/testrun/components/progress-initiate-form/progress-initiate-form.component.ts index cf323ec11..754d0ea5b 100644 --- a/modules/ui/src/app/pages/testrun/components/progress-initiate-form/progress-initiate-form.component.ts +++ b/modules/ui/src/app/pages/testrun/components/progress-initiate-form/progress-initiate-form.component.ts @@ -149,7 +149,7 @@ export class ProgressInitiateFormComponent private createInitiateForm() { this.initiateForm = this.fb.group({ - firmware: ['', [this.deviceValidators.deviceStringFormat()]], + firmware: ['', [this.deviceValidators.firmwareStringFormat()]], test_modules: new FormArray([]), }); }