mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[MNT-24909] Check if property constraint is handled by validators available in ADF (#10696)
This commit is contained in:
parent
97970735fe
commit
f7e521607c
@ -185,5 +185,23 @@ describe('CardViewBaseItemModel', () => {
|
|||||||
const itemModel = new CarViewCustomItemModel(constrainedProperties);
|
const itemModel = new CarViewCustomItemModel(constrainedProperties);
|
||||||
expect(itemModel.isValid(itemModel.value)).toBe(true);
|
expect(itemModel.isValid(itemModel.value)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should log warning when validator type is not supported by validatorsMap', () => {
|
||||||
|
spyOn(console, 'warn');
|
||||||
|
const constrainedProperties: CardViewItemProperties = {
|
||||||
|
...properties,
|
||||||
|
value: 'test.',
|
||||||
|
constraints: [
|
||||||
|
{
|
||||||
|
id: 'custom-constraint-id',
|
||||||
|
type: 'org.test.constraint'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
const itemModel = new CarViewCustomItemModel(constrainedProperties);
|
||||||
|
expect(itemModel.isValid(itemModel.value)).toBe(true);
|
||||||
|
expect(console.warn).toHaveBeenCalledWith('Validator for type org.test.constraint is not supported');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -50,7 +50,11 @@ export abstract class CardViewBaseItemModel<T = any> {
|
|||||||
for (const constraint of props.constraints) {
|
for (const constraint of props.constraints) {
|
||||||
if (constraint.type !== 'LIST') {
|
if (constraint.type !== 'LIST') {
|
||||||
const validatorFactory = validatorsMap[constraint.type.toLowerCase()];
|
const validatorFactory = validatorsMap[constraint.type.toLowerCase()];
|
||||||
this.validators.push(validatorFactory(constraint.parameters));
|
if (validatorFactory !== undefined) {
|
||||||
|
this.validators.push(validatorFactory(constraint.parameters));
|
||||||
|
} else {
|
||||||
|
console.warn(`Validator for type ${constraint.type} is not supported`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user