mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[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:
@@ -85,4 +85,24 @@ describe('CardViewTextItemModel', () => {
|
||||
expect(itemModel.displayValue).toBe('testpiped-testpiped-testpiped-Banuk-1-2-3');
|
||||
});
|
||||
});
|
||||
|
||||
it('should validate based on defined constraints', () => {
|
||||
const constrainedProperties = {
|
||||
label: 'Tribe',
|
||||
value: 'test',
|
||||
key: 'tribe',
|
||||
dataType: 'd:text',
|
||||
constraints: [{
|
||||
id: 'constraint-id',
|
||||
type: 'REGEX',
|
||||
parameters: { expression: '^(?=.*test).*' }
|
||||
}]
|
||||
};
|
||||
|
||||
const itemModel = new CardViewTextItemModel(constrainedProperties);
|
||||
expect(itemModel.isValid(itemModel.value)).toBe(true);
|
||||
|
||||
itemModel.value = 'dummy';
|
||||
expect(itemModel.isValid(itemModel.value)).toBe(false, '`dummy` is not a constraint expression pattern');
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user