Fix a bug in which validation check on key was incorrect