I would delete this. The decoding will throw an exception if the format is invalid. There's no need to restrict it explicitly.