diff --git a/lib/core/src/lib/card-view/models/card-view-baseitem.model.spec.ts b/lib/core/src/lib/card-view/models/card-view-baseitem.model.spec.ts index debe20df9f..6420bbe3e7 100644 --- a/lib/core/src/lib/card-view/models/card-view-baseitem.model.spec.ts +++ b/lib/core/src/lib/card-view/models/card-view-baseitem.model.spec.ts @@ -185,5 +185,23 @@ describe('CardViewBaseItemModel', () => { const itemModel = new CarViewCustomItemModel(constrainedProperties); 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'); + }); }); }); diff --git a/lib/core/src/lib/card-view/models/card-view-baseitem.model.ts b/lib/core/src/lib/card-view/models/card-view-baseitem.model.ts index f4fe8ca90e..f6cf0906e6 100644 --- a/lib/core/src/lib/card-view/models/card-view-baseitem.model.ts +++ b/lib/core/src/lib/card-view/models/card-view-baseitem.model.ts @@ -50,7 +50,11 @@ export abstract class CardViewBaseItemModel { for (const constraint of props.constraints) { if (constraint.type !== 'LIST') { 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`); + } } } }