diff --git a/dist/adapter.esm.js b/dist/adapter.esm.js index cfb0379284b4494717d6f17efd522a282f4a8dd7..21ced71a3bcb874e7945aa992d73409f9d46d12a 100644 --- a/dist/adapter.esm.js +++ b/dist/adapter.esm.js @@ -101,7 +101,9 @@ class Adapter { if (validation.valid) { const type = this.protocol.getType(parsed); this.protocol.decode(type, parsed); - } + } else { + this.protocol.receivedInvalid(parsed, validation); + } }); return response; }) diff --git a/dist/adapter.js b/dist/adapter.js index a20309e819894e7919d0d6543980db6457850882..5eb10e870ffaf2543563c15392f601ad0baa5dbb 100644 --- a/dist/adapter.js +++ b/dist/adapter.js @@ -103,7 +103,9 @@ class Adapter { if (validation.valid) { const type = this.protocol.getType(parsed); this.protocol.decode(type, parsed); - } + } else { + this.protocol.receivedInvalid(parsed, validation); + } }); return response; }) diff --git a/dist/protocol.esm.js b/dist/protocol.esm.js index 12070d6b8dd73ae06419f942d01dbefbea0c734c..2cb93de2e679f20f7c02275d4ad6dec1033c2c8a 100644 --- a/dist/protocol.esm.js +++ b/dist/protocol.esm.js @@ -80,6 +80,18 @@ class GenericProtocol { return message; } + + /** + * Invoked on receiving an invalid message from the backbone + * + * @param {object} message + * @param {object} validation + * @returns {*} + */ + receivedInvalid(message, validation) { + return message; + } + /** * Optionally invoked before delivering a message to the backbone * diff --git a/dist/protocol.js b/dist/protocol.js index 7242ff8222914b1709c377ecc5eddfa1f5b0e30d..e7099c90863e0347ef87daab85d482d474007ef8 100644 --- a/dist/protocol.js +++ b/dist/protocol.js @@ -82,6 +82,18 @@ class GenericProtocol { return message; } + + /** + * Invoked on receiving an invalid message from the backbone + * + * @param {object} message + * @param {object} validation + * @returns {*} + */ + receivedInvalid(message, validation) { + return message; + } + /** * Optionally invoked before delivering a message to the backbone * diff --git a/src/adapter/index.js b/src/adapter/index.js index 3d48d0edeadcc25c1cffbb6e3695cab0261118b0..8489f83fe66d5cc9529f1f9c1ed999103d5b47ca 100644 --- a/src/adapter/index.js +++ b/src/adapter/index.js @@ -101,7 +101,9 @@ export class Adapter { if (validation.valid) { const type = this.protocol.getType(parsed); this.protocol.decode(type, parsed); - } + } else { + this.protocol.receivedInvalid(parsed, validation); + } }); return response; }) diff --git a/src/protocol/index.js b/src/protocol/index.js index 1d7f69f99ba560d8b7c2af8d873959e4c5b5af05..dcc87cdfcd5b139515e1033906e433dd75cb49f3 100644 --- a/src/protocol/index.js +++ b/src/protocol/index.js @@ -80,6 +80,18 @@ export class GenericProtocol { return message; } + + /** + * Invoked on receiving an invalid message from the backbone + * + * @param {object} message + * @param {object} validation + * @returns {*} + */ + receivedInvalid(message, validation) { + return message; + } + /** * Optionally invoked before delivering a message to the backbone *