add a helper method to validate the string to be saved into database