err.code is used to indicate the validation failure