Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
role="alert"
aria-live="assertive">
<span
>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.</span
>
Expand All @@ -49,7 +49,7 @@
role="alert"
aria-live="assertive">
<span
>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.</span
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
);
});
});
Expand Down Expand Up @@ -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.'
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))),
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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([]),
});
}
Expand Down