add tenant code validator pattern
This commit is contained in:
parent
9e7559b078
commit
e36ceb4ed9
|
@ -44,6 +44,7 @@
|
||||||
<input matInput type="text" name="code" [formControl]="formGroup.get('code')" required>
|
<input matInput type="text" name="code" [formControl]="formGroup.get('code')" required>
|
||||||
<mat-error *ngIf="formGroup.get('code').hasError('backendError')">{{formGroup.get('code').getError('backendError').message}}</mat-error>
|
<mat-error *ngIf="formGroup.get('code').hasError('backendError')">{{formGroup.get('code').getError('backendError').message}}</mat-error>
|
||||||
<mat-error *ngIf="formGroup.get('code').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-error *ngIf="formGroup.get('code').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
<mat-error *ngIf="formGroup.get('code').hasError('pattern')">{{'TENANT-EDITOR.VALIDATION.INVALID-CODE' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
|
|
|
@ -43,7 +43,7 @@ export class TenantEditorModel extends BaseEditorModel implements TenantPersist
|
||||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||||
baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] });
|
baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] });
|
||||||
baseValidationArray.push({ key: 'name', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'name')] });
|
baseValidationArray.push({ key: 'name', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'name')] });
|
||||||
baseValidationArray.push({ key: 'code', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'code')] });
|
baseValidationArray.push({ key: 'code', validators: [Validators.required, Validators.pattern('^[a-z0-9\_\]+$'), BackendErrorValidator(this.validationErrorModel, 'code')] });
|
||||||
baseValidationArray.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'description')] });
|
baseValidationArray.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'description')] });
|
||||||
baseValidationArray.push({ key: 'hash', validators: [] });
|
baseValidationArray.push({ key: 'hash', validators: [] });
|
||||||
|
|
||||||
|
|
|
@ -1369,6 +1369,9 @@
|
||||||
},
|
},
|
||||||
"TENANT-EDITOR": {
|
"TENANT-EDITOR": {
|
||||||
"NEW": "New Tenant",
|
"NEW": "New Tenant",
|
||||||
|
"VALIDATION": {
|
||||||
|
"INVALID-CODE": "Invalid code"
|
||||||
|
},
|
||||||
"FIELDS": {
|
"FIELDS": {
|
||||||
"NAME": "Name",
|
"NAME": "Name",
|
||||||
"CODE": "Code",
|
"CODE": "Code",
|
||||||
|
|
Loading…
Reference in New Issue