[ACA-3742] Metadata - constraints validation (#5908)

* card min max value validator

* card match value validator

* card value length validator

* map validators to constraint type

* add minmax

* update exported validators

* register validators based on constraint type

* translate errors with parameters

* tests
This commit is contained in:
Cilibiu Bogdan
2020-07-24 18:58:07 +03:00
committed by GitHub
parent 154ca07aad
commit aa3d890342
15 changed files with 223 additions and 12 deletions

View File

@@ -27,6 +27,7 @@ import { MatChipsModule } from '@angular/material/chips';
import { ClipboardService } from '../../../clipboard/clipboard.service';
import { DebugElement } from '@angular/core';
import { TranslateModule } from '@ngx-translate/core';
import { CardViewItemValidator } from '../../interfaces/card-view-item-validator.interface';
describe('CardViewTextItemComponent', () => {
@@ -441,7 +442,7 @@ describe('CardViewTextItemComponent', () => {
});
it('should set the errorMessages properly if the editedValue is invalid', async () => {
const expectedErrorMessages = ['Something went wrong'];
const expectedErrorMessages = [{ message: 'Something went wrong' } as CardViewItemValidator];
component.property.isValid = () => false;
component.property.getValidationErrors = () => expectedErrorMessages;
@@ -450,7 +451,7 @@ describe('CardViewTextItemComponent', () => {
await fixture.whenStable();
updateTextField(component.property.key, 'updated-value');
expect(component.errorMessages).toBe(expectedErrorMessages);
expect(component.errors).toBe(expectedErrorMessages);
});
it('should update the property value after a successful update attempt', async () => {