Skip to content

Commit

Permalink
feat: policy id validation
Browse files Browse the repository at this point in the history
  • Loading branch information
illfixit committed Sep 15, 2024
1 parent 388438d commit 6e804d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Injectable} from '@angular/core';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {DataOfferFormValidators} from 'src/app/core/validators/data-offer-form-validators';
import {ExpressionFormControls} from '../../../../component-library/policy-editor/editor/expression-form-controls';
import {noWhitespacesOrColonsValidator} from '../../../../core/validators/no-whitespaces-or-colons-validator';
import {
Expand All @@ -24,11 +25,16 @@ export class PolicyDefinitionCreatePageForm {
constructor(
private formBuilder: FormBuilder,
private expressionFormControls: ExpressionFormControls,
private validators: DataOfferFormValidators,
) {}

buildFormGroup(): FormGroup<PolicyDefinitionCreatePageFormModel> {
return this.formBuilder.nonNullable.group({
id: ['', [Validators.required, noWhitespacesOrColonsValidator]],
id: [
'',
[Validators.required, noWhitespacesOrColonsValidator],
[this.validators.policyIdExistsValidator],
],
treeControls: this.expressionFormControls.formGroup,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<mat-error *ngIf="ctrl.invalid && ctrl.errors?.pattern">{{
validationMessages.invalidWhitespacesOrColonsMessage
}}</mat-error>
<mat-error *ngIf="ctrl.invalid && ctrl.errors?.idAlreadyExists">{{
validationMessages.idExistsErrorMessage
}}</mat-error>
</mat-form-field>

<div class="form-section-title">Policy Expression</div>
Expand Down

0 comments on commit 6e804d4

Please sign in to comment.