Adding onInvalid handler

Change-Id: I510eb41fa62d2da4a39197bca2802a31021481c9